Skip to content

Commit 4da4100

Browse files
committed
Fix: formatting in prepareStackTrace when error isn't of instance Error
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
1 parent 6035ef5 commit 4da4100

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source-map-support.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,18 @@ function wrapCallSite(frame) {
384384
}
385385

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

394-
return error + stack.map(function(frame) {
394+
var name = error.name || 'Error';
395+
var message = error.message || '';
396+
var errorString = name + ": " + message;
397+
398+
return errorString + stack.map(function(frame) {
395399
return '\n at ' + wrapCallSite(frame);
396400
}).join('');
397401
}

0 commit comments

Comments
 (0)