November 2018
Beginner
132 pages
2h 57m
English
Koa implements a default error handler, which works well for many situations. It is essentially middleware with a try...catch statement defined at the very top of the Koa middleware stack. If no other error handler is defined, all errors thrown when the application is running will flow into Koa's default error handler.
The default handler uses the status code of err.status when available, else it uses 500 (for Internal Server Error). It also sends back err.message as the response if err.expose is set to true.
If err.expose is set to false, then it generates a message from the error code of the error thrown. For example, for the 400 Bad Request error, the message generated will be Invalid Request.
When sending ...
Read now
Unlock full access