3 ms·
One thing I see people do quite a lot is to write error messages for, or assume error messages are intended for, users of the client application that calls the
by fy20 5y ago
One thing I see people do quite a lot is to write error messages for, or assume error messages are intended for, users of the client application that calls the API.
I feel this is a mistake because in the backend you have absolutely no context about why the call was made, not to mention you aren't going to i18n the errors.
I'd suggest to return an error message designed for the developers using your API, and an error code (as RFC-7807 does) that is machine parsable to identify the type of error, so client applications can react to it and/or display a user friendly error message.