question: How do I customize internal HttpErrors with custom Http errors with KoaDriver?
See original GitHub issueI was sending custom HttpErrors that changes the response to the user but I can’t do this when I’m validating request bodies because it’s using the one that came with the library.
This is the response I want to throw when a validation fails;
{
"status": false,
"message": "Validation errors.",
"errors": "ValidationError[] from class validator"
}
This is what it currently returns
{
"name": "BadRequestError",
"message": "Invalid body, check 'errors' property for more info.",
"errors": "ValidationError[] from class validator"
}
One way that I could find is to use this but since I’m using Koa I can’t use it.
One workaround for this is disabling the validator from @Body()
and calling class-validator inside the request function.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (1 by maintainers)
Top Results From Across the Web
HTTP Errors <httpErrors> - Microsoft Learn
In the Add Custom Error Page dialog box, under Status code, type the number of the HTTP status code for which you want...
Read more >How do I display custom error pages in Asp.Net Mvc 3?
I have tried using a combination <custom errors> and <httpErrors> with no luck - the standard error or blank page is still displayed....
Read more >How To Implement Custom Error Responses in Express - Auth0
Therefore, you need to customize error responses to provide the client with more details about the problem that occurred.
Read more >Custom error pages - Sitefinity CMS Setup and maintenance
Navigate to Administration » Settings » Advanced » Pages » Custom error pages » Error types » Create new. In HTTP status code,...
Read more >Custom errors, extending Error - The Modern JavaScript Tutorial
When we develop something, we often need our own error classes to reflect specific things that may go wrong in our tasks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I solve it. IDK why, but the
ValidationError
was in theerror.errors
and it was an array ofValidationError
. so i did this kind of trick to send the error message to the client:and with this trick, I resolve it. HOPE this would be helpful later. 🎯
Closing this as stale.
If the issue still persists, you may open a new Q&A in the discussions tab and someone from the community may be able to help.