4 ms·
So the problem with these "good" examples is that they expose the end user to Errors, messages likely not written by you or your team and moreso not intended fo
by donatj 4y ago
So the problem with these "good" examples is that they expose the end user to Errors, messages likely not written by you or your team and moreso not intended for general consumption - you need to be really careful about doing so because an unexpected error could expose lots of troubling things like credentials and general information about your system you'd rather not expose.
We've got a general rule of thumb never to expose the message of an Error to the end user.
- collinvandyck76 4y agoYep, that's why you'd want the error handler to try and type assert the error to something like an HTTPError where that's an interface you control. If it is an HTTPError, then you can "trust" the code/message and write that back to the user. Otherwise, 500 with a generic response body.