Comparing version 2.0.3 to 2.1.0
@@ -11,2 +11,3 @@ /* errorex | ||
const path = require('path'); | ||
const merge = require('putil-merge'); | ||
const StackFrame = require('stackframe'); | ||
@@ -29,10 +30,7 @@ | ||
if (msg instanceof Error) { | ||
super(msg.message); | ||
for (const key of Object.keys(msg)) | ||
if (['name', 'stack'].indexOf(key) < 0) | ||
this[key] = msg[key]; | ||
super(); | ||
this.set(msg); | ||
this.stack = ErrorEx._mergeStack(msg.stack, this.stack); | ||
} else | ||
super(msg && format(msg, ...args)); | ||
this.name = this.constructor === ErrorEx ? 'Error' : this.constructor.name; | ||
} | ||
@@ -42,2 +40,10 @@ | ||
* | ||
* @return {string} | ||
*/ | ||
get name() { | ||
return this.constructor === ErrorEx ? 'Error' : this.constructor.name; | ||
} | ||
/** | ||
* | ||
* @param {Boolean} [noInternal=false] | ||
@@ -69,3 +75,8 @@ * @return {Array|*} | ||
if (!this._stackFrames) | ||
this._stackFrames = ErrorEx.parseStack(this.getStack(noInternal)); | ||
Object.defineProperty(this, '_stackFrames', { | ||
enumerable: false, | ||
writable: true, | ||
configurable: true, | ||
value: ErrorEx.parseStack(this.getStack(noInternal)) | ||
}); | ||
return this._stackFrames; | ||
@@ -83,5 +94,6 @@ } | ||
if (typeof property === 'object') { | ||
for (const k of Object.keys(property)) { | ||
this[k] = property[k]; | ||
} | ||
merge(this, property, { | ||
adjunct: true, descriptor: true, | ||
filter: (_, n) => !['name', 'stack'].includes(n) | ||
}); | ||
} else | ||
@@ -88,0 +100,0 @@ this[property] = value; |
{ | ||
"name": "errorex", | ||
"description": "'Extensible Error Class' implementation and predefined additional error types for javascript", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"author": "Panates Ltd.", | ||
@@ -19,2 +19,3 @@ "contributors": [ | ||
"dependencies": { | ||
"putil-merge": "^3.2.0", | ||
"stackframe": "^1.0.4" | ||
@@ -24,6 +25,6 @@ }, | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.6.1", | ||
"eslint": "^5.12.1", | ||
"eslint-config-google": "^0.10.0", | ||
"nyc": "^13.0.1", | ||
"mocha": "^5.2.0" | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0" | ||
}, | ||
@@ -42,3 +43,3 @@ "engines": { | ||
"nyc": { | ||
"temp-directory": "./coverage/.nyc_output" | ||
"temp-dir": "./coverage/.nyc_output" | ||
}, | ||
@@ -45,0 +46,0 @@ "scripts": { |
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
10537
231
2
+ Addedputil-merge@^3.2.0
+ Addedputil-merge@3.13.0(transitive)