www/long-stack-traces/lib/long-stack-traces.js
function makeWrappedCallback(callback, frameLocation) {
        // add a fake stack frame. we can't get a real one since we aren't inside the original function
        var traceError = new Error();
        traceError.__location = frameLocation;
        traceError.__previous = currentTraceError;
        return function() {
            // if (currentTraceError) {
            //     FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead?
            //     console.warn("(long-stack-traces) Internal Error: currentTrace already set.");
            // }
            // restore the trace
            currentTraceError = traceError;
            try {
                return callback.apply(this, arguments);
            } catch (e) {
                console.error("Uncaught " + e.stack);
                if (LST.rethrow)
                    throw ""; // TODO: throw the original error, or undefined?
            } finally {
                // clear the trace so we can check that none is set above.
                // TODO: could we remove this for slightly better performace?
                currentTraceError = null;
            }
        }
    }
function makeWrappedCallback(callback, frameLocation) {
        // add a fake stack frame. we can't get a real one since we aren't inside the original function
        var traceError = new Error();
        traceError.__location = frameLocation;
        traceError.__previous = currentTraceError;
        return function() {
            // if (currentTraceError) {
            //     FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead?
            //     console.warn("(long-stack-traces) Internal Error: currentTrace already set.");
            // }
            // restore the trace
            currentTraceError = traceError;
            try {
                return callback.apply(this, arguments);
            } catch (e) {
                console.error("Uncaught " + e.stack);
                if (LST.rethrow)
                    throw ""; // TODO: throw the original error, or undefined?
            } finally {
                // clear the trace so we can check that none is set above.
                // TODO: could we remove this for slightly better performace?
                currentTraceError = null;
            }
        }
    }
function makeWrappedCallback ( callback , frameLocation ) { // add a fake stack frame. we can't get a real one since we aren't inside the original function var traceError = new Error ( ) ; traceError . __location = frameLocation ; traceError . __previous = currentTraceError ; return function ( ) { // if (currentTraceError) { //     FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead? //     console.warn("(long-stack-traces) Internal Error: currentTrace already set."); // } // restore the trace currentTraceError = traceError ; try { return callback . apply ( this , arguments ) ; } catch ( e ) { console . error ( "Uncaught " + e . stack ) ; if ( LST . rethrow ) throw "" ; // TODO: throw the original error, or undefined? } finally { // clear the trace so we can check that none is set above. // TODO: could we remove this for slightly better performace? currentTraceError = null ; } } }
Takes a callback function and name, and captures a stack trace, returning a new callback that restores the stack frame This function adds a single function call overhead during callback registration vs. inlining it in wrapRegistationFunction
Takes a callback function and name and captures a stack trace returning a new callback that restores the stack frame This function adds a single function call overhead during callback registration vs . inlining it in wrapRegistationFunction