Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ExceptionFilter Doc #100

Closed
itizarsa opened this issue Mar 11, 2025 · 3 comments
Closed

Update ExceptionFilter Doc #100

itizarsa opened this issue Mar 11, 2025 · 3 comments

Comments

@itizarsa
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The example in the exception filter doc is not working, I wasn't able to set the status & response by mutating the context.res as those were read-only properties.

response.status = status;
    response.body = {
      statusCode: status,
      timestamp: new Date().toISOString(),
      path: request.url,
    };

Describe the solution you'd like

Update the docs with a working example like below

return ctx.newResponse(JSON.stringify(body), {
			status: status.code,
			headers: ctx.res.headers
		});

Describe alternatives you've considered

Additional context

jsr:@danet/core@2
@itizarsa
Copy link
Contributor Author

@Sorikairox If the above is correct, I can raise a PR with correct example

@Sorikairox
Copy link
Collaborator

@itizarsa Thank you for raising this issue!

We are indeed missing a test to set the response code in https://github.com/Savory/Danet/blob/main/spec/exception-filter.test.ts

So we would need to add one test there and add a correct example in the documentation indeed!

@Sorikairox
Copy link
Collaborator

@itizarsa I added a test to confirm this behavior. I will update the documentation with your example. Thank you again for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants