Skip to content

Commit

Permalink
Merge pull request #237 from legraphista/fix/195
Browse files Browse the repository at this point in the history
Fix: formatting in prepareStackTrace when error isn't of instance Error
  • Loading branch information
LinusU committed Apr 8, 2019
2 parents 6035ef5 + 2515a8f commit f2a0fbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source-map-support.js
Expand Up @@ -384,14 +384,18 @@ function wrapCallSite(frame) {
}

// This function is part of the V8 stack trace API, for more info see:
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
// https://v8.dev/docs/stack-trace-api
function prepareStackTrace(error, stack) {
if (emptyCacheBetweenOperations) {
fileContentsCache = {};
sourceMapCache = {};
}

return error + stack.map(function(frame) {
var name = error.name || 'Error';
var message = error.message || '';
var errorString = name + ": " + message;

return errorString + stack.map(function(frame) {
return '\n at ' + wrapCallSite(frame);
}).join('');
}
Expand Down
10 changes: 10 additions & 0 deletions test.js
Expand Up @@ -622,3 +622,13 @@ it('handleUncaughtExceptions is true with existing listener', function(done) {
done();
});
});

it('normal console.trace', function(done) {
compareStdout(done, createMultiLineSourceMap(), [
'require("./source-map-support").install();',
'console.trace("test");'
], [
'Trace: test',
/^ at Object\.<anonymous> \((?:.*[/\\])?line2\.js:1002:102\)$/
]);
});

0 comments on commit f2a0fbf

Please sign in to comment.