mirror of
https://github.com/denoland/deno.git
synced 2024-11-04 08:54:20 -05:00
f91fa16661
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.
23 lines
572 B
JavaScript
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);
|