Comparing version 0.2.11 to 0.2.12
@@ -7,3 +7,3 @@ var util = require('util') | ||
, normalizeError = require('./formatError').normalizeError | ||
, fileNameFilter = [__filename, require.resolve('hookit'), 'domain.js', 'Domain.emit'] | ||
, fileNameFilter = [path.dirname(__filename), require.resolve('hookit'), 'domain.js', 'Domain.emit'] | ||
, delimitter = '\n ----------------------------------------\n' | ||
@@ -46,5 +46,11 @@ , hasGuardedWithoutLST | ||
function _trycatchOnError(e) { | ||
if (!e.caught && false !== e.domainThrown && false !== e.domain_thrown) { | ||
d.exit() | ||
throw e | ||
if (!e.caught) { | ||
if (false === e.domainThrown || false === e.domain_thrown) { | ||
// "error" emitted, passed directly to domain | ||
e = normalizeError(e) | ||
console.log('here: ', e.stack) | ||
} else { | ||
d.exit() | ||
throw e | ||
} | ||
} | ||
@@ -58,2 +64,3 @@ | ||
} else if (d.currentStack) { | ||
console.log('there') | ||
e.stack += delimitter + d.currentStack | ||
@@ -60,0 +67,0 @@ } |
{ | ||
"name": "trycatch", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "An asynchronous domain-based exception handler with long stack traces for node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/CrabDude/trycatch", |
@@ -17,2 +17,4 @@ var trycatch = require('../lib/trycatch') | ||
describe('EventEmitter' + str, function() { | ||
var delimitter = '----------------------------------------' | ||
before(function() { | ||
@@ -83,3 +85,3 @@ trycatch.configure({ | ||
var ee = new EE | ||
function foo() { | ||
@@ -98,2 +100,16 @@ throw new Error('Event handler should have been removed') | ||
}) | ||
it('should catch emitted errors passed directly to domain', function(done) { | ||
trycatch(function () { | ||
var ee = new EE | ||
process.nextTick(function () { | ||
ee.emit('error', new Error('Async')) | ||
}) | ||
}, function(err) { | ||
assert.equal(err.message, 'Async') | ||
assert.notEqual(err.stack, undefined) | ||
assert.equal(err.stack.split(delimitter).length, longStackTraces ? 2 : 1) | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -100,0 +116,0 @@ } |
@@ -41,5 +41,3 @@ var assert = require('assert'), | ||
assert.equal(count, 3) | ||
if (longStackTraces) { | ||
assert.equal(err.stack.split(delimitter).length, 1) | ||
} | ||
assert.equal(err.stack.split(delimitter).length, 1) | ||
done() | ||
@@ -62,5 +60,3 @@ }) | ||
++count | ||
if (longStackTraces) { | ||
assert.equal(err.stack.split(delimitter).length, 2) | ||
} | ||
assert.equal(err.stack.split(delimitter).length, longStackTraces ? 2 : 1) | ||
throw err | ||
@@ -76,5 +72,3 @@ }) | ||
if (longStackTraces) { | ||
assert.equal(err.stack.split(delimitter).length, 3) | ||
} | ||
assert.equal(err.stack.split(delimitter).length, longStackTraces ? 3 : 1) | ||
done() | ||
@@ -99,5 +93,3 @@ }) | ||
if (longStackTraces) { | ||
assert.equal(err.stack.split(delimitter).length, 2) | ||
} | ||
assert.equal(err.stack.split(delimitter).length, longStackTraces ? 2 : 1) | ||
throw err | ||
@@ -114,5 +106,3 @@ }, 0) | ||
if (longStackTraces) { | ||
assert.equal(err.stack.split(delimitter).length, 3) | ||
} | ||
assert.equal(err.stack.split(delimitter).length, longStackTraces ? 3 : 1) | ||
done() | ||
@@ -119,0 +109,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
47048
725