Closed vikmeup closed 4 years ago
What does "Validator not found" mean - should this also be a HTTP 404 error code? The summary hints at this being a HTTP 500 status
Yes, there is two problems:
1) wrong status code 2) error response is not well designed, there is an error value inside an error object
Let's design a new version of handlers for Platform REST API? I recommend reading that before https://github.com/microsoft/api-guidelines https://medium.com/@schneidenbach/restful-api-best-practices-and-common-pitfalls-7a83ba3763b5
+1
{
"error": {
"code": 123,
"message": "Link alias conflict"
}
}
{
"error": {
"code": 123,
"message": "Some error"
}
}
Best format for errors.
Some remarks about the error handling :
Errors are managed within the router logic, it might be good to consider using a handler so that all the logic regarding the api error response can be gathered into one place Some code about how to use the gin middleware https://stackoverflow.com/questions/48224908/better-error-handling
Putting the HTTP code
as code
seems a bit redundant since this information can be directly retrieved from the response object.
Maybe it would be good to defined "application specific error code" which can be a number code "0001", a string code "A0001" etc.. That would help to make things easier for the consumer of the api so that he can implement his logics accordingly the error code (better than doing a switch on a long message string)
An example of list of error code
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html
I recommend RFC 7807: "Problem Details for HTTP APIs". Simple and widely used. https://tools.ietf.org/html/rfc7807#section-3
Summary of Bug
Currently error response type has duplicated data and not intuitive to use
Expected Behavior
TODO: Define