Custom errors to send custom status codes
See original GitHub issueI am trying to implement a validation chain, where some errors should return 400 (with a specific message) but some other should return 403 (with a specific message). I have found no neat way to do this, as I handle all validationResult(req)
at the end of the validation chain. It would be cool to be able set like withStatus
that gets attached to the results, or maybe even withCustom
to add custom things to it. Or maybe there is an easier, more intuitive way?
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Can we create custom HTTP Status codes? - Stack Overflow
Yes, as long as you respect the class -- that is, 2xx for success, 4xx for Client error, etc. So you can return...
Read more >How To Implement Custom Error Responses in Express - Auth0
Learn why you may need custom error responses on 4xx errors, what a good custom format looks like, and how to apply it...
Read more >Custom error responses (beta) · Cloudflare Rules docs
During the beta, you can define custom error responses using inline templates and specify the response's content type and HTTP status code.
Read more >A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >How to set Custom Error Message and Status code for an ...
This article goes over the process to define custom error messages and status codes in an HTTP service, details how to handle them...
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 FreeTop 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
Top GitHub Comments
Will try it when I get a chance, thanks.
Does this work?