2019-02-09 16:55:40 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-30 14:45:36 -04:00
|
|
|
import * as msg from "gen/cli/msg_generated";
|
2019-02-09 16:55:40 -05:00
|
|
|
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);
|
2019-04-07 20:51:43 -04:00
|
|
|
const offset = msg.FormatError.createFormatError(builder, errString_);
|
2019-02-09 16:55:40 -05:00
|
|
|
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!;
|
|
|
|
}
|