Files
ipfs-bch-wallet-consumer/src/controllers/rest-api/middleware/error.js
T
2021-07-06 15:08:07 -07:00

12 lines
244 B
JavaScript

module.exports = function errorMiddleware () {
return async (ctx, next) => {
try {
await next()
} catch (err) {
ctx.status = err.status || 500
ctx.body = err.message
ctx.app.emit('error', err, ctx)
}
}
}