0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-30 09:08:00 -04:00
denoland-deno/cli/rt/40_error_stack.js
Bartek Iwańczuk f91fa16661
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.
2020-12-10 14:45:41 +01:00

23 lines
572 B
JavaScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
((window) => {
const core = window.Deno.core;
function opFormatDiagnostics(diagnostics) {
return core.jsonOpSync("op_format_diagnostic", diagnostics);
}
function opApplySourceMap(location) {
const res = core.jsonOpSync("op_apply_source_map", location);
return {
fileName: res.fileName,
lineNumber: res.lineNumber,
columnNumber: res.columnNumber,
};
}
window.__bootstrap.errorStack = {
opApplySourceMap,
opFormatDiagnostics,
};
})(this);