code: function commonErrorHandler(err, req, res, next) { // jshint ignore:line
  
    debug(err);
  
    // if we got here without an error, it's a 404 case
    if (!err) {
      err = new NotFoundError();
    }
  
    // here we've got an error, it could be a different one than
    // the one we've constructed, so provide defaults to be safe
    err.message = err.message || 'Internal Server Error';
  
    res
      .status(err.code || err.statusCode || 500)
      .type('application/json')
      .send(stringify(err));
  }
docs: Middleware for sending errors based on passed error
  @param {Error}    err  - error object
  @param {Object}   req  - http request
  @param {Object}   res  - http response
  @param {Function} next - next