code: function handleError(err, msg, code, req, res){
    logError(err, msg, code, req);
  
    var response = buildErrorObject({
      err: err,
      msg: msg,
      httpCode: code
    });
  
    res.statusCode = response.httpCode;
    res.end(JSON.stringify(response.errorFields));
  }
docs: generic error handler