Comparing version 1.0.3 to 1.0.4
@@ -115,4 +115,16 @@ 'use strict'; | ||
]; | ||
var names = ['BatchError', 'PageError', 'SequenceError']; | ||
var error = this.error instanceof BatchError ? this.error.toString(level + 1) : $npm.u.inspect(this.error); | ||
var error; | ||
if (this.error instanceof Error) { | ||
if (names.indexOf(this.error.name) === -1) { | ||
error = $npm.u.inspect(this.error) + '\n' + $npm.utils.getStack(this.error, level + 1); | ||
} else { | ||
error = this.error.toString(level + 1); | ||
} | ||
} else { | ||
error = $npm.u.inspect(this.error); | ||
} | ||
lines.push(gap1 + 'error: ' + error); | ||
@@ -119,0 +131,0 @@ |
@@ -95,3 +95,3 @@ 'use strict'; | ||
level = level > 0 ? parseInt(level) : 0; | ||
var gap0 = $npm.utils.messageGap(level), | ||
@@ -106,4 +106,18 @@ gap1 = $npm.utils.messageGap(level + 1), | ||
]; | ||
var names = ['BatchError', 'PageError', 'SequenceError']; | ||
var error; | ||
if (this.error instanceof Error) { | ||
if (names.indexOf(this.error.name) === -1) { | ||
error = $npm.u.inspect(this.error) + '\n' + $npm.utils.getStack(this.error, level + 1); | ||
} else { | ||
error = this.error.toString(level + 1); | ||
} | ||
} else { | ||
error = $npm.u.inspect(this.error); | ||
} | ||
lines.push(gap1 + 'error: ' + $npm.u.inspect(this.error)); | ||
lines.push(gap1 + 'error: ' + error); | ||
lines.push(gap0 + '}'); | ||
@@ -110,0 +124,0 @@ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var exp = { | ||
getStack: stat.getStack, | ||
isPromise: stat.isPromise, | ||
@@ -10,0 +11,0 @@ isReadableStream: stat.isReadableStream, |
@@ -37,3 +37,17 @@ 'use strict'; | ||
function getStack(error, level) { | ||
// from the call stack, we take only lines starting with the client's | ||
// source code, and only those that contain a full path inside brackets, | ||
// indicating a reference to the client's source code: | ||
var gap = messageGap(level); | ||
return error.stack.split('\n').filter(function (line) { | ||
return line.match(/\(.*(\\+|\/+).*\)/); // contains \ or / inside () | ||
}).map(function (line) { | ||
return gap + line; | ||
}).join('\n'); | ||
} | ||
module.exports = { | ||
getStack: getStack, | ||
isPromise: isPromise, | ||
@@ -40,0 +54,0 @@ isReadableStream: isReadableStream, |
{ | ||
"name": "spex", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Specialized Promise Extensions", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
60128
1419