Unable to catch errors globally from inversify-express-utils controllers

You should use setErrorConfig when init a server, like this:

server.setErrorConfig((app) => {
  app.use((err, req, res, next) => {
    if (err) {
      if (err instanceof HttpRedirectError) {
        return res.redirect(err.redirectUrl);
      }
      return res.json(Requester.createError(err));
    }
    next();
  });
});

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top