Closed 0xflotus closed 5 years ago
I'm not entirely sure what you mean. Could you elaborate, please?
Currently you can throw a NotFoundException or a BadRequestException. The Client then will see a JSON Response (content-type: application/json) with error code and message as body. So why not implement the RFC 7807 to standardize the error responses?
Example:
Now:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
statusCode: 400,
error: "Bad Request"
}
Then:
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
Content-Language: en
{
"type": "https://example.net/validation-error",
"title": "Your request parameters didn't validate.",
"invalid-params": [ {
"name": "age",
"reason": "must be a positive integer"
},
{
"name": "color",
"reason": "must be 'green', 'red' or 'blue'"}
]
}
Thanks for the clarification.
We don't plan to introduce any breaking changes right now. If anyone wants to follow RFC 7807, it should be very simple to achieve with exception filters
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Feature Request
RFC 7807 conform Problem Details
Is your feature request related to a problem? Please describe.
If I write an RESTful API with NestJS, I have to care for showing errors to clients on my own.
Describe the solution you'd like
How awesome would it be to use a standard way of returning errors?
What is the motivation / use case for changing the behavior?
It would be easier for Clients to work with NestJS backends, because there is a standard way to handle with errors.