diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-12-10 14:45:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 14:45:41 +0100 |
commit | f91fa16661fa10fd029e6cf26008faee95233143 (patch) | |
tree | 3d45e2ebb3e93e0947ac382b944bf2600b9c36c4 /cli/rt/99_main.js | |
parent | b7faa27704458b4bbb0b43b15bcb16b13e7c3c4f (diff) |
refactor(core): stack trace mapping (#8660)
This commit adds "Deno.core.createPrepareStackTrace". This function
was moved from "cli/rt/40_error_stack.js" to unify handling of stack frames in core
(before this PR there was implicit dependency on logic in "core/error.rs::JsError").
Unfortunately formatting logic must still be duplicated in "cli/error.js::PrettyJsError"
to provide coloring, but currently there's no solution to this problem.
"createPrepareStackTrace" can accept a single argument; a function that takes
a location and provides source mapped location back.
Diffstat (limited to 'cli/rt/99_main.js')
-rw-r--r-- | cli/rt/99_main.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/rt/99_main.js b/cli/rt/99_main.js index 40c9c636f..2aa140990 100644 --- a/cli/rt/99_main.js +++ b/cli/rt/99_main.js @@ -164,9 +164,16 @@ delete Object.prototype.__proto__; // TODO(bartlomieju): a very crude way to disable // source mapping of errors. This condition is true // only for compiled standalone binaries. + let prepareStackTrace; if (s.applySourceMaps) { - errorStack.setPrepareStackTrace(Error); + prepareStackTrace = core.createPrepareStackTrace( + errorStack.opApplySourceMap, + ); + } else { + prepareStackTrace = core.createPrepareStackTrace(); } + Error.prepareStackTrace = prepareStackTrace; + return s; } |