2019-02-09 16:55:40 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-08-24 16:20:48 -04:00
|
|
|
import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
|
|
|
|
import { assert } from "./util";
|
2019-02-09 16:55:40 -05:00
|
|
|
|
|
|
|
export function formatError(errString: string): string {
|
2019-08-24 16:20:48 -04:00
|
|
|
const builder = flatbuffers.createBuilder();
|
|
|
|
const errString_ = builder.createString(errString);
|
|
|
|
const offset = msg.FormatError.createFormatError(builder, errString_);
|
|
|
|
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!;
|
2019-02-09 16:55:40 -05:00
|
|
|
}
|