@jymfony/exceptions
Advanced tools
Comparing version 0.1.0-alpha.9 to 0.1.0-alpha.10
@@ -0,4 +1,7 @@ | ||
Error.stackTraceLimit = Infinity; | ||
require('./lib/Exception'); | ||
require('./lib/BadMethodCallException'); | ||
require('./lib/InvalidArgumentException'); | ||
require('./lib/DomainException'); | ||
require('./lib/LogicException'); | ||
@@ -5,0 +8,0 @@ require('./lib/OutOfBoundsException'); |
const UNKNOWN_FUNCTION = '?'; | ||
class Exception extends Error { | ||
constructor(message, code = null, previous = undefined) { | ||
super(message); | ||
/** | ||
* @param {...} args | ||
*/ | ||
constructor(...args) { | ||
super(); | ||
delete this.message; | ||
return this.__construct(...args); | ||
} | ||
/** | ||
* Constructor. | ||
* | ||
* @param {string} message | ||
* @param {int|null} [code = null] | ||
* @param {Exception} [previous] | ||
*/ | ||
__construct(message, code = null, previous = undefined) { | ||
/** | ||
@@ -28,5 +43,5 @@ * @type {string} | ||
Error.captureStackTrace(this, this.constructor); | ||
this._originalStack = this.stack.split('\n').slice(2).join('\n'); | ||
this._originalStack = this.stack.split('\n').join('\n'); | ||
delete this.message; | ||
this._updateStack(); | ||
} | ||
@@ -37,3 +52,3 @@ | ||
* | ||
* @returns {[Object<string, string>]} | ||
* @returns {Object.<string, string>[]} | ||
*/ | ||
@@ -44,2 +59,12 @@ get stackTrace() { | ||
/** | ||
* @returns {string} | ||
*/ | ||
get message() { | ||
return this._message; | ||
} | ||
/** | ||
* @param {string} message | ||
*/ | ||
set message(message) { | ||
@@ -50,6 +75,5 @@ this._message = message; | ||
get message() { | ||
return this._message; | ||
} | ||
/** | ||
* @private | ||
*/ | ||
_updateStack() { | ||
@@ -64,3 +88,3 @@ this.stack = this.constructor.name + ': ' + this.message + '\n\n' + this._originalStack; | ||
* | ||
* @returns {[Object<string, string>]} | ||
* @returns {Object.<string, string>[]} | ||
*/ | ||
@@ -67,0 +91,0 @@ static parseStackTrace(error) { |
{ | ||
"name": "@jymfony/exceptions", | ||
"version": "0.1.0-alpha.9", | ||
"version": "0.1.0-alpha.10", | ||
"description": "Jymfony exception (core package)", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": ">=8.10.0" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
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
9161
25
228