diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-09-18 14:40:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 15:40:04 +0200 |
commit | 75ca013f076f443dce3d38f31a168295351ed0e5 (patch) | |
tree | a8f369429ff650516a513a0416e8984f457835a4 /core/02_error.js | |
parent | f840906943849f5a09981e172d57e84301b77386 (diff) |
fix(cli/fmt_errors): Abbreviate long data URLs in stack traces (#12127)
Co-authored-by: Mike White <mike.white@auctane.com>
Diffstat (limited to 'core/02_error.js')
-rw-r--r-- | core/02_error.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/02_error.js b/core/02_error.js index c6f642630..4ec9f7267 100644 --- a/core/02_error.js +++ b/core/02_error.js @@ -70,7 +70,7 @@ } // Keep in sync with `cli/fmt_errors.rs`. - function formatLocation(callSite) { + function formatLocation(callSite, formatFileNameFn) { if (callSite.isNative()) { return "native"; } @@ -80,7 +80,7 @@ const fileName = callSite.getFileName(); if (fileName) { - result += fileName; + result += formatFileNameFn(fileName); } else { if (callSite.isEval()) { const evalOrigin = callSite.getEvalOrigin(); @@ -106,7 +106,7 @@ } // Keep in sync with `cli/fmt_errors.rs`. - function formatCallSite(callSite) { + function formatCallSite(callSite, formatFileNameFn) { let result = ""; const functionName = callSite.getFunctionName(); @@ -159,11 +159,11 @@ } else if (functionName) { result += functionName; } else { - result += formatLocation(callSite); + result += formatLocation(callSite, formatFileNameFn); return result; } - result += ` (${formatLocation(callSite)})`; + result += ` (${formatLocation(callSite, formatFileNameFn)})`; return result; } @@ -205,7 +205,7 @@ * columnNumber: number * }} sourceMappingFn */ - function createPrepareStackTrace(sourceMappingFn) { + function createPrepareStackTrace(sourceMappingFn, formatFileNameFn) { return function prepareStackTrace( error, callSites, @@ -235,7 +235,10 @@ const formattedCallSites = []; for (const callSite of mappedCallSites) { ArrayPrototypePush(error.__callSiteEvals, evaluateCallSite(callSite)); - ArrayPrototypePush(formattedCallSites, formatCallSite(callSite)); + ArrayPrototypePush( + formattedCallSites, + formatCallSite(callSite, formatFileNameFn), + ); } const message = error.message !== undefined ? error.message : ""; const name = error.name !== undefined ? error.name : "Error"; |