@jymfony/exceptions
Advanced tools
Comparing version 0.1.0-alpha.14 to 0.1.0-alpha.15
@@ -101,3 +101,3 @@ const UNKNOWN_FUNCTION = '?'; | ||
static parseStackTrace(error) { | ||
const regex = /^\s*at (?:((?:\[object object])?\S+(?: \[as \S+])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i, | ||
const regex = /^\s*at (?:async )?(?:((?:\[object object])?\S+(?: \[as \S+])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i, | ||
lines = error.stack.split('\n'), | ||
@@ -104,0 +104,0 @@ stack = []; |
{ | ||
"name": "@jymfony/exceptions", | ||
"version": "0.1.0-alpha.14", | ||
"version": "0.1.0-alpha.15", | ||
"description": "Jymfony exception (core package)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,18 +6,40 @@ const expect = require('chai').expect; | ||
describe('[Exceptions] Exception', function () { | ||
it('registered in global namespace', function () { | ||
it('registered in global namespace', () => { | ||
return expect(Exception).to.be.not.undefined; | ||
}); | ||
it('Is instance of Error', function () { | ||
it('Is instance of Error', () => { | ||
return expect(new Exception()).to.be.an.instanceof(Error); | ||
}); | ||
it('Inherits name', function () { | ||
it('Inherits name', () => { | ||
return expect((new TestException()).name).to.be.equal('TestException'); | ||
}); | ||
it('Captures stack', function () { | ||
it('Captures stack', () => { | ||
const ex = new Exception(); | ||
return expect(ex.stack).to.be.not.empty; | ||
}); | ||
const [ major, minor ] = process.versions.v8.split('.', 3); | ||
it('should parse async stack traces', 7 < ~~major || (7 === ~~major && 3 <= ~~minor) ? () => { | ||
async function functionOne() { | ||
await new Promise((resolve) => { | ||
setTimeout(() => resolve(), 1); | ||
}); | ||
throw new Error('Something Bad'); | ||
} | ||
async function functionTwo() { | ||
await functionOne(); | ||
} | ||
functionTwo().catch((error) => { | ||
const stack = Exception.parseStackTrace(error); | ||
expect(stack).to.have.length(2); | ||
expect(stack[0].function).to.be.equal('functionOne'); | ||
expect(stack[1].function).to.be.equal('functionTwo'); | ||
}); | ||
} : undefined); | ||
}); |
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
12506
7
320