error_handler.js 333 B

123456789101112131415
  1. 'use strict';
  2. module.exports = () => {
  3. return async function errorHandler(ctx, next) {
  4. try {
  5. await next();
  6. } catch (err) {
  7. console.log(err);
  8. console.log(err.code);
  9. // const { message } = err;
  10. // const json = JSON.parse(message);
  11. // ctx.body = json;
  12. ctx.status = 400;
  13. }
  14. };
  15. };