Improve (add) friendly JSON API error messages (at least generic ones)

If I POST to /posts and something is wrong, here is what’s returned as an error:

image

image

only the code shows - no message (not friendly). This is the error when I typo the secret.

Here’s another form of error, leaving out a field:

image

bad “CSRF” – No one knows what the heck does that means. You can see 403 forbidden and get the hint for the code, but let’s say it wasn’t a forbidden one: It goes back to the 500 error.

These errors… really suck haha. Suggestions:

Invalid Parameters: Missing xx field(s)

Forbidden: Invalid secret/key combo

Something like these. Since error messages are so common, I actually thought I was glitched out since I only had a code returned, so even something generic would be better than nothing.

It would also be more intuitive if the errors were in json for consideration of future additions, and to be more intuitive to handling error standards of most other API’s.

{
  "error": {
    "msg": "Invalid API/Secret Combination: Extra info here",
    "code": "ACCESS_DENIED"
  {
}

Thoughts?