atsid/generator-ats-node-webapp

View on GitHub
generators/server-full/templates/server/initialization/sections/error_handling/error_handler.js

Summary

Maintainability
A
0 mins
Test Coverage
const log = require('debug')('app:errors');

module.exports = (err, req, res, next) => {
  if (req.body && req.body.password) {
    delete req.body.password;
  }
  log(`handling error on path ${req.url} with payload`, req.body, err, err.stack);

  const statusCode = err.httpStatus || 500;
  const message = err.message || 'An error occurred with the services.';
  res.status(statusCode).send(message);
  next();
};