Comparing version 1.4.0 to 1.4.1
var path = require('path') | ||
, node_modules = path.sep + 'node_modules' + path.sep | ||
, colors | ||
, delimitter = ' ----------------------------------------' | ||
, chalk | ||
@@ -37,2 +38,4 @@ // use chalk module, if available | ||
err.normalized = true | ||
err.originalStack = err.stack | ||
err.coreThrown = isCoreError(err) | ||
@@ -56,3 +59,3 @@ err.catchable = isCatchableError(err) | ||
// Can't catch invalid input errors more than 1 layer deep | ||
return !isCoreSlice(err.stack.split('\n')[2]) | ||
return !isCoreSlice(err.originalStack.split('\n')[2]) | ||
} | ||
@@ -65,3 +68,3 @@ | ||
function isCoreError(err) { | ||
return true !== err.coerced && isCoreSlice(err.stack.split('\n')[1]) | ||
return true !== err.coerced && isCoreSlice(err.originalStack.split('\n')[1]) | ||
} | ||
@@ -99,6 +102,6 @@ | ||
type = "default"; | ||
} else if (line.indexOf('(') >= 0) { | ||
} else if (line === delimitter || line.substring(0, 5) === 'Error') { | ||
return line | ||
} else { | ||
type = "node" | ||
} else { | ||
return line | ||
} | ||
@@ -105,0 +108,0 @@ |
@@ -73,3 +73,4 @@ var util = require('util') | ||
e = formatError(e) | ||
// Normalize again for rethrown | ||
e = normalizeError(e) | ||
@@ -118,2 +119,3 @@ if (isLST && parentStack) { | ||
// Get new stack and chop off leading non-stack portion | ||
// MUST use Error.captureStackTrace to avoid stack filtering | ||
obj = {} | ||
@@ -137,6 +139,7 @@ originalError.captureStackTrace(obj) | ||
if (err) { | ||
err = normalizeError(err) | ||
if (hasDomain) { | ||
d.emit('error', normalizeError(err)) | ||
d.emit('error', err) | ||
} else { | ||
handleException(formatError(normalizeError(err))) | ||
handleException(err) | ||
} | ||
@@ -143,0 +146,0 @@ } |
{ | ||
"name": "trycatch", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "An asynchronous domain-based exception handler with long stack traces for node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/CrabDude/trycatch", |
@@ -60,4 +60,5 @@ var trycatch = require('../lib/trycatch') | ||
process.nextTick(function() { | ||
Error.stackTraceLimit = 0 | ||
var err = new Error('Async') | ||
delete err.stack | ||
Error.stackTraceLimit = 10 | ||
throw err | ||
@@ -64,0 +65,0 @@ }) |
@@ -17,3 +17,8 @@ var trycatch = require('../lib/trycatch') | ||
'long-stack-traces': Boolean(longStackTraces) | ||
, colors: { | ||
}) | ||
}) | ||
beforeEach(function() { | ||
trycatch.configure({ | ||
colors: { | ||
node: 'red' | ||
@@ -23,2 +28,8 @@ , node_modules: 'red' | ||
} | ||
}) | ||
}) | ||
afterEach(function() { | ||
trycatch.configure({ | ||
colors: null | ||
, filter: null | ||
@@ -29,3 +40,3 @@ }) | ||
it('should be colored', function() { | ||
new Error().stack.split('\n').forEach(function(value, key) { | ||
new Error().stack.split(delimitter)[0].split('\n').forEach(function(value, key) { | ||
if (key === 0) return | ||
@@ -67,9 +78,13 @@ | ||
var stack | ||
, referenceStack | ||
referenceStack = new Error().stack.split(delimitter)[0].split('\n') | ||
trycatch.configure({ | ||
filter: ['trycatch'] | ||
filter: ['configure.test.js'] | ||
}) | ||
stack = new Error().stack.split(delimitter)[0].split('\n') | ||
assert.equal(stack.length, 1) | ||
assert.equal(referenceStack.length-1, stack.length) | ||
}) | ||
@@ -76,0 +91,0 @@ |
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
50654
834