index.js
function(callback) {
    // capture current error location
    var trace_error = new Error();
    trace_error.id = ERROR_ID++;
    trace_error.__previous__ = current_trace_error;
    trace_error.__trace_count__ = current_trace_error ? current_trace_error.__trace_count__ + 1 : 1;
    limit_frames(trace_error);
    var new_callback = function() {
        current_trace_error = trace_error;
        trace_error = null;
        var res = callback.apply(this, arguments);
        current_trace_error = null;
        return res;
    };
    new_callback.__original_callback__ = callback;
    return new_callback;
}
function(callback) {
    // capture current error location
    var trace_error = new Error();
    trace_error.id = ERROR_ID++;
    trace_error.__previous__ = current_trace_error;
    trace_error.__trace_count__ = current_trace_error ? current_trace_error.__trace_count__ + 1 : 1;
    limit_frames(trace_error);
    var new_callback = function() {
        current_trace_error = trace_error;
        trace_error = null;
        var res = callback.apply(this, arguments);
        current_trace_error = null;
        return res;
    };
    new_callback.__original_callback__ = callback;
    return new_callback;
}
function ( callback ) { // capture current error location var trace_error = new Error ( ) ; trace_error . id = ERROR_ID ++ ; trace_error . __previous__ = current_trace_error ; trace_error . __trace_count__ = current_trace_error ? current_trace_error . __trace_count__ + 1 : 1 ; limit_frames ( trace_error ) ; var new_callback = function ( ) { current_trace_error = trace_error ; trace_error = null ; var res = callback . apply ( this , arguments ) ; current_trace_error = null ; return res ; } ; new_callback . __original_callback__ = callback ; return new_callback ; }
wrap a callback to capture any error or throw and thus the stacktrace
wrap a callback to capture any error or throw and thus the stacktrace