| The error messages could be better yet. The example uses a different code per issue, for instance: "user/email_required". Most integrators will build their UI to highlight the input fields that contain an error. Making them parse the `code` field (or special-case each possible code) is pretty toilsome. // from blog post
{
"code": "user/email_required",
"message": "The parameter [email] is required."
}
Make it parseable: // improved
{
"message": "An email is required.",
"error": "missing_parameter",
"parameter": "user.email"
}
In addition, I:* rewrote `message` to be an acceptable error message displayed to (non-technical) end-users * moved message to be the first field: some developer tools will truncate the JSON response body when presenting it in the stack trace. --- As an added bonus, structured data allows you to analyze `error` frequencies and improve frontend validation or write better error messages: https://twitter.com/VicVijayakumar/status/149509216182142976... |
https://datatracker.ietf.org/doc/html/rfc7807