-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
HttpErrors.InternalServerError does not report my custom message #3657
Comments
You might find that you are running into strong error handling behaviour so I don't think that it is a bug but by design. 5xx errors are obscured and only deliver details to the end user in debug mode. Maybe catch internal server errors and rethrow(as non-5xx) as you see fit? Not sure that is the best idea though... be careful. https://loopback.io/doc/en/lb3/Using-strong-error-handler.html |
thanks @dougal83 for your thought. The strong-error-handler package is for lb3 and I can't find anything similar in lb4, also it is not mentioned in the feature parity page. Anyway, maybe the behaviour is by design but:
I'd like to know what is the opinion of loopback team members on this... |
To be helpful I googled it for you: |
Thank you @dougal83 for helping out, you are right - LB4 is using strong-error-handler under the hood. The details are described in our documentation here: https://loopback.io/doc/en/lb4/Sequence.html#handling-errors @sertal70 you can enable |
Closing due to inactivity. |
Hi all,
I'm facing an issue using
HttpErrors
. In any controller, if I throw anyHttpErrors.*
I can pass a custom message and this is then included in the JSON returned to client. For instance, if I do:then the client receive the following JSON (note the
name
andmessage
fields):But if I throw an
Internal Server Error
like this:the JSON returned to the client is:
as you can see, the
name
field is not reported and its content is in themessage
field , which should instead contain my custom message.Steps to reproduce
In any controller of a lb4 application throw the
InternalServerError
Error using a custom message:Current Behavior
The following JSON is returned to the client:
Expected Behavior
I would expect to receive a JSON similar to the one returned for others HTTP Errors, having the following format:
Additional information
The text was updated successfully, but these errors were encountered: