3 ms·
> It can be really hard to get anybody outside engineering interested in error messages until they see them show up in production. IMHO any given request shoul
by Alex3917 9y ago
> It can be really hard to get anybody outside engineering interested in error messages until they see them show up in production.
IMHO any given request should be able to return multiple errors for the different stakeholders who will be consuming them. A good JSON error response could be something like:
{ 'display_error': '', 'field_errors': { 'field1': []}, 'internal_error': '' }
The idea is that display error is something shown to the user, possibly a form-level error when relevant. Field errors are validation errors for user-submitted data. And internal errors are things that aren't shown to users, and are only meant as a way for backend and frontend devs to communicate amongst themselves to help debugging.
- mdaniel 9y agohttps://tools.ietf.org/html/rfc7807 https://tools.ietf.org/html/rfc7807 ("Problem Details for HTTP APIs") may interest you (but just for clarity: I only know about it, but haven't attempted to apply it to any situation)