loopback/server/middleware/error-handler.js

22 lines
642 B
JavaScript
Raw Normal View History

2016-05-03 22:50:21 +00:00
// Copyright IBM Corp. 2015. All Rights Reserved.
// Node module: loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
var expressErrorHandler = require('errorhandler');
expressErrorHandler.title = 'Loopback';
module.exports = errorHandler;
function errorHandler(options) {
if (!options || options.includeStack !== false) {
return expressErrorHandler(options);
} else {
var baseHandler = expressErrorHandler(options);
return function errorHandler(err, req, res, next) {
delete err.stack;
return baseHandler(err, req, res, next);
};
}
}