Express js error handling

后端 未结 5 1631
无人及你
无人及你 2020-12-15 18:19

I\'m trying to get error handling running with express but instead of seeing a response of \"error!!!\" like I expect I see \"some exception\" on the console and then the pr

5条回答
  •  感动是毒
    2020-12-15 18:44

    I had the same problem and couldn't figure out what was wrong. The thing is if you have the express errorHandler defined then your custom error handler is never being called. If you have the next code, simply remove it:

    if ('development' === app.get('env')) {
      app.use(express.errorHandler());
    }
    

    Worked for me:)

提交回复
热议问题