Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent API error messages #134

Open
lstkz opened this issue Jul 24, 2018 · 0 comments
Open

Consistent API error messages #134

lstkz opened this issue Jul 24, 2018 · 0 comments

Comments

@lstkz
Copy link

lstkz commented Jul 24, 2018

Hello,

Recently we discussed in the Topcoder Community, and people have different opinions regarding errors messages.

From your best practices:

Response messages must be self-descriptive. A good error message response might look something like this:

// (1)
{
    "code": 1234,
    "message" : "Something bad happened",
    "description" : "More details"
}

or for validation errors:

// (2)
{
    "code" : 2314,
    "message" : "Validation Failed",
    "errors" : [
        {
            "code" : 1233,
            "field" : "email",
            "message" : "Invalid email"
        },
        {
            "code" : 1234,
            "field" : "password",
            "message" : "No password provided"
        }
      ]
}

Based on my understanding, (1) schema can be used as a general error format, and (2) schema can be used for a specific situation (validation errors in this case).
That means error responses don't have to have the exact format with the same properties.
Some developers insist that all error responses should be consistent and be the same.

Could you clarify it according to your best practices in this project?

@vpanjganj vpanjganj self-assigned this Nov 22, 2018
@vpanjganj vpanjganj added this to the Maintenance milestone Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants