@jymfony/exceptions
Advanced tools
Comparing version 0.1.0-alpha.6 to 0.1.0-alpha.8
@@ -25,8 +25,8 @@ const UNKNOWN_FUNCTION = '?'; | ||
*/ | ||
this.message = message; | ||
if ('function' === typeof Error.captureStackTrace) { | ||
Error.captureStackTrace(this, this.constructor); | ||
} else { | ||
this.stack = (new Error(message)).stack; | ||
} | ||
this._message = message; | ||
Error.captureStackTrace(this, this.constructor); | ||
this._originalStack = this.stack.split('\n').slice(2).join('\n'); | ||
delete this.message; | ||
} | ||
@@ -43,2 +43,15 @@ | ||
set message(message) { | ||
this._message = message; | ||
this._updateStack(); | ||
} | ||
get message() { | ||
return this._message; | ||
} | ||
_updateStack() { | ||
this.stack = this.constructor.name + ': ' + this.message + '\n\n' + this._originalStack; | ||
} | ||
/** | ||
@@ -52,7 +65,6 @@ * Parses a stack trace from an error instance. | ||
static parseStackTrace(error) { | ||
const regex = /^\s*at (?:((?:\[object object])?\S+(?: \[as \S+])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i; | ||
let lines = error.stack.split('\n'), | ||
stack = [], | ||
parts, | ||
element; | ||
const regex = /^\s*at (?:((?:\[object object])?\S+(?: \[as \S+])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i, | ||
lines = error.stack.split('\n'), | ||
stack = []; | ||
let parts, element; | ||
@@ -59,0 +71,0 @@ for (let i = 0, j = lines.length; i < j; ++i) { |
{ | ||
"name": "@jymfony/exceptions", | ||
"version": "0.1.0-alpha.6", | ||
"version": "0.1.0-alpha.8", | ||
"description": "Jymfony exception (core package)", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node ./tests.js test/**", | ||
"coverage": "istanbul cover ./tests.js test/**" | ||
"test": "node ./tests.js test/**" | ||
}, | ||
@@ -22,3 +21,2 @@ "keywords": [ | ||
"chai": "^3.5.0", | ||
"istanbul": "^0.4", | ||
"mocha": "^3.0" | ||
@@ -25,0 +23,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
2
171
8159
21