custom http code
See original GitHub issueCurrently koa seems to only handle standard code.
When i use a code like 420 with ctx.throw('custom message', 420)
, koa replace it by a 500.
When i use …
const err = new Error('custom message');
err.status = 420;
err.expose = true;
throw err;
… koa throw the error invalid status code: 420
I need to use custom code. Is there a way to add custom code to koa ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 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 >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are ... Custom error pages · List of FTP...
Read more >HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >A Complete Guide and List of HTTP Status Codes
Understanding HTTP Status Code Classes · 100s: Informational codes indicating that the request initiated by the browser is continuing. · 200s: ...
Read more >How to return a custom HTTP status code using WebAPI 2
This post will give you an example on how to return such a custom HTTP code. Have a look here for the natively...
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
so good answer is
Would be usefull to give access to statuses in app
Look at the tests here: https://github.com/koajs/koa/blob/master/test/response/status.js