Skip to content

Commit

Permalink
Fix: formatting in prepareStackTrace when error isn't of instance Error
Browse files Browse the repository at this point in the history
console.trace sends on object with name and message instead of an Error,
thus rendering the function unusable due to erroneous message output of
"[object Object]". This fixes #195
  • Loading branch information
legraphista committed Mar 23, 2019
1 parent 6035ef5 commit 4da4100
Showing 1 changed file with 6 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

0 comments on commit 4da4100

Please sign in to comment.