From 2235dd795d3cc6c24ff1bdd1bbdcd110b4b0bdfc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 24 Aug 2019 13:20:48 -0700 Subject: Revert json ops (#2814) * Revert "port more ops to JSON (#2809)" This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1. --- js/format_error.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'js/format_error.ts') diff --git a/js/format_error.ts b/js/format_error.ts index dde0f6a58..6670b05e2 100644 --- a/js/format_error.ts +++ b/js/format_error.ts @@ -1,9 +1,17 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import * as dispatch from "./dispatch"; -import { sendSync } from "./dispatch_json"; +import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers"; +import { assert } from "./util"; -// TODO(bartlomieju): move to `repl.ts`? export function formatError(errString: string): string { - const res = sendSync(dispatch.OP_FORMAT_ERROR, { error: errString }); - return res.error; + 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!; } -- cgit v1.2.3