Skip to content

How to add custom Error Handler? #125

@ak99372

Description

@ak99372

I'd like to add a global error handler either on express or resourcejs level (to do additional logging/handling) but I don't see an options or params to do that and on top the default error handler seems to swallow the errors.

const error = (err, req, res, next) => {
      if (err) {
        res.status(400).json({
          status: 400,
          message: err.message || err,
        });
      }
      else {
        return next();
      }
    };

    routeStack = [...routeStack, error.bind(this)]

Any suggestions on how to let errors through to express middleware or have a custom error handler added to resourcejs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions