@c8/errors
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -18,12 +18,12 @@ 'use strict' | ||
// We probably just want to convert these to standard 500 | ||
// These errors are automatically converted to 500, can be changed if needs be with something like: | ||
if ( | ||
origErr instanceof EvalError || | ||
origErr instanceof SyntaxError || | ||
origErr instanceof RangeError || | ||
origErr instanceof ReferenceError || | ||
origErr instanceof TypeError || | ||
origErr instanceof URIError | ||
err instanceof EvalError || | ||
err instanceof SyntaxError || | ||
err instanceof RangeError || | ||
err instanceof ReferenceError || | ||
err instanceof TypeError || | ||
err instanceof URIError | ||
) { | ||
return Boom.badImplementation(origErr.message, errParams) | ||
return Boom.XXXXX(origErr.message, errParams) | ||
} | ||
@@ -55,4 +55,5 @@ */ | ||
* Translates c8 error to boom error based defined mapping or default mapping | ||
* @param {Error} err Service error | ||
* @param {object} mapping c8 -> Boom mapping | ||
* @param {Error} err Error to convert | ||
* @param {object} customErrors | ||
* @param {object} customMapping | ||
* @return {Error} Boom error | ||
@@ -69,4 +70,3 @@ */ | ||
const origErr = _.cloneDeep(err) | ||
const errParams = _.omit(err, 'message') | ||
const errParams = _.omit(_.cloneDeep(err)) | ||
@@ -76,8 +76,8 @@ let boomError = (() => { | ||
for (let customErr of mapping[boomErr]) { | ||
if (Errors[customErr] && origErr instanceof Errors[customErr]) { | ||
return Boom[boomErr](origErr.message, errParams) | ||
if (Errors[customErr] && err instanceof Errors[customErr]) { | ||
return Boom[boomErr](err.message, errParams) | ||
} | ||
} | ||
} | ||
})() || Boom.wrap(origErr) // defaults to HTTP 500 status | ||
})() || Boom.wrap(err) // defaults to HTTP 500 status | ||
@@ -84,0 +84,0 @@ // Make err.data publicly available so we can send extra intel like custom error codes. |
{ | ||
"name": "@c8/errors", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Common errors and their utils used by C8 management", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5676