Skip to content

Commit

Permalink
added unhandled error options
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-pig-walrus committed Jun 3, 2016
1 parent 9cfeacc commit 4cdc96c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const extractJsonContent = (error, includeStackTrace) => {
* @param {boolean} [options.showStackTrace] show stack trace in error output, default: false
* @param {boolean} [options.showNonPublic] show underlying error embedded in non-public errors, default: false
* @param {boolean} [options.includeRawError] include actual error object with no changes, default: false
* @param {Function} [options.onUnhandledError] call this function for any error without status attribute, default: null
* @returns {Function} error handler suitable for placement on root application.
*/
module.exports = (options) => {
Expand All @@ -51,6 +52,9 @@ module.exports = (options) => {
status = err.status
json = extractJsonContent(err, o.showStackTrace)
} else {
if (options.onUnhandledError) {
options.onUnhandledError(err)
}
status = 500
json = { error: 'An internal server error occurred.' }
if (o.showNonPublic) {
Expand Down

0 comments on commit 4cdc96c

Please sign in to comment.