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
|
|
|
|
|
2015-07-05 17:20:34 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|