Tuesday 6 June 2017

Why isn't my error being returned in my express response?

I have a default error handler setup in my express application as so.

 app.use(function unhandledErrorHandler(err, req, res, next) {
   res.status(err.status || 500).json({
     error: err
   });
 });

However whenever I call a route and an error is thrown I am getting a response that looks like this.

{
  "error": {}
}

Can someone help my understand why express is returning my error as an Object?



via C Deuter

No comments:

Post a Comment