Comparing version 1.5.3 to 1.5.4
@@ -128,3 +128,4 @@ var path = require('path') | ||
module.exports.formatError = formatError | ||
module.exports.formatStack = formatStack | ||
module.exports.coerceToError = coerceToError | ||
module.exports.addNonEnumerableValue = addNonEnumerableValue |
var domain = require('domain') | ||
// , util = require('util') | ||
, path = require('path') | ||
@@ -9,7 +8,7 @@ , hookit = require('hookit') | ||
, formatErrorWithOptions = formatErrorModule.formatError | ||
, formatStackWithOptions = formatErrorModule.formatStack | ||
, coerceToError = formatErrorModule.coerceToError | ||
, addNonEnumerableValue = formatErrorModule.addNonEnumerableValue | ||
, delimitter = '\n ----------------------------------------\n' | ||
, stackHolder = {isTrycatchStackHolder: true} | ||
, originalError = global.Error | ||
, stackHolder = {} | ||
, defaultColors | ||
@@ -135,9 +134,5 @@ , defaultFileNameFilter | ||
// MUST use Error.captureStackTrace to avoid stack filtering | ||
originalError.captureStackTrace(stackHolder) | ||
Error.captureStackTrace(stackHolder) | ||
stack = stackHolder.stack | ||
// When stackTraceLimit === 0, stack is empty | ||
if (stackHolder.stack) { | ||
stack = stackHolder.stack.substr(16) | ||
} | ||
if (trycatch.currentStack) { | ||
@@ -236,2 +231,11 @@ stack += delimitter + trycatch.currentStack | ||
function formatStack(stack) { | ||
return formatStackWithOptions(stack | ||
, { | ||
lineFormatter: trycatch.format | ||
, colors: options.colors | ||
, filter: options.filter | ||
}) | ||
} | ||
/* Config Logic */ | ||
@@ -244,3 +248,3 @@ | ||
// No longer necessary, but nice to have | ||
originalError.stackTraceLimit = options['long-stack-traces'] ? Infinity : 10 | ||
Error.stackTraceLimit = options['long-stack-traces'] ? Infinity : 10 | ||
} | ||
@@ -283,13 +287,17 @@ | ||
Error.prepareStackTrace = prepareStackTrace | ||
function prepareStackTrace(err, frames) { | ||
var stack = FormatStackTrace.call(this, err, frames) | ||
// return stack only for stackHolder from getUpdatedCurrentStack::captureStackTrace | ||
if (err.isTrycatchStackHolder) return stack | ||
if (err === stackHolder) { | ||
// When stackTraceLimit === 0, stack is empty | ||
stack = stack && stack.substr(16) | ||
return formatStack(stack) | ||
} | ||
stack = formatError(err, stack) | ||
if (options['long-stack-traces'] && trycatch.currentStack) { | ||
stack += delimitter + trycatch.currentStack | ||
} | ||
return formatError(err, stack) | ||
return stack | ||
} | ||
originalError.prepareStackTrace = prepareStackTrace | ||
@@ -296,0 +304,0 @@ // Pass callback wrapping function to hookit |
{ | ||
"name": "trycatch", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "An asynchronous domain-based exception handler with long stack traces for node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/CrabDude/trycatch", |
54797
952