Error handling in Koa.js?

How do you handle errors in Koa.js? I'm just learning the design, and do not really understand how to do it, but I think that should be a universal variant. There are plenty of stata, but the ones I found are reduced to the option below:

Do so, but not sure what the right thing to do...
const errorhandler = async (ctx, next) => {
 try {
 await next();
 } catch (err) {
 ctx.status = err.statusCode || err.status || 500;
 ctx.body = {code: err.statusCode, message: err.message};'error', err, ctx);
April 4th 20 at 13:12
0 answer

Find more questions by tags Node.js