elsewhencode / elsewhencode/project-guidelines

Consistent API error messages

Đang mở
#134 0 bình luận 0 reaction 1 người được giao Được @vpanjganj nhận Xem trên GitHub
improvement question
Ngôn ngữ chính
JavaScript
Star
29.4k
Fork
3.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.