-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Preserve API invoked internal server error custom messages. #18
Preserve API invoked internal server error custom messages. #18
Conversation
Add an additional properties to the internal server error in case is manually invoked by the user for always allowing the custom message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Can you also add a test to verify what happens if you are not using the internal httpErrors
?
I don't think I've understand what kind of test you mean. Like importing httpErrors directly and return an error object created from there? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the test I meant is already present in another file 😅
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!!!
…fy#18 Signed-off-by: Lam Wei Li <[email protected]>
Signed-off-by: Lam Wei Li <[email protected]>
This PR is aimed to allow the customization of the
500
errors that are generated via the available APIs and not from thrown errors, even when theerrorHandler
options is set totrue
.The reasoning behind this change is that having the uncaught exceptions not leaked to the users is a valuable things to have but in the current implementation even the errors generated via the APIs will be masked even if the custom error is passed by the developer. To allow custom
500
errors we have to disable the "anti leaking" function.With this PR I've added an additional flag to the error message if it is generated via the API on the
fastify.httpErrors
andreply
object to allow them to keep their message and not to log an error that is generated always in the same way.Doing this will keep the API usage the same on every error (can set a custom message and the generated error is not logged by default) and keep the masking on thrown errors.