Re:The art of the error message
by Alex3917 on Sunday January 07, 2018 @06:48PM
(#16093533)
> 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:
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.
Re:The art of the error message
by mdaniel on Sunday January 07, 2018 @08:00PM
(#16093868)
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)
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.