mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 18:12:39 +00:00
Support scoped variables, unblock REPL async op, and REPL error colors (#1721)
This commit is contained in:
parent
1502051453
commit
1d36eb47eb
18 changed files with 329 additions and 54 deletions
21
js/format_error.ts
Normal file
21
js/format_error.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as msg from "gen/msg_generated";
|
||||
import * as flatbuffers from "./flatbuffers";
|
||||
import { sendSync } from "./dispatch";
|
||||
import { assert } from "./util";
|
||||
|
||||
export function formatError(errString: string): string {
|
||||
const builder = flatbuffers.createBuilder();
|
||||
const errString_ = builder.createString(errString);
|
||||
msg.FormatError.startFormatError(builder);
|
||||
msg.FormatError.addError(builder, errString_);
|
||||
const offset = msg.FormatError.endFormatError(builder);
|
||||
const baseRes = sendSync(builder, msg.Any.FormatError, offset);
|
||||
assert(baseRes != null);
|
||||
assert(msg.Any.FormatErrorRes === baseRes!.innerType());
|
||||
const formatErrorResMsg = new msg.FormatErrorRes();
|
||||
assert(baseRes!.inner(formatErrorResMsg) != null);
|
||||
const formattedError = formatErrorResMsg.error();
|
||||
assert(formatError != null);
|
||||
return formattedError!;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue