Express 3 error middleware not being called

前端 未结 4 1926
温柔的废话
温柔的废话 2021-02-18 18:46

I am trying to setup error handling for my express app and running into the following problem.

I defined an error middleware and add it as the last middleware:



        
4条回答
  •  时光说笑
    2021-02-18 19:19

    EDIT 2 (sabtioagoIT) works. But just for those who missed it, emostar's solution also works. I understood to move the error handling 'use' call to the end, but there seems to be an easier option as emoster suggests, use app.router (before the error handling 'use' call).

提交回复
热议问题