From eafd40feabaf14f9f88748c66fa319519fd69072 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 2 Mar 2020 14:20:16 -0800 Subject: Do not convert exceptions to JSON and back (#4214) --- cli/ops/errors.rs | 21 --------------------- cli/ops/worker_host.rs | 11 +++++------ 2 files changed, 5 insertions(+), 27 deletions(-) (limited to 'cli/ops') diff --git a/cli/ops/errors.rs b/cli/ops/errors.rs index c588759cf..4d2ce1bef 100644 --- a/cli/ops/errors.rs +++ b/cli/ops/errors.rs @@ -1,7 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use super::dispatch_json::{Deserialize, JsonOp, Value}; use crate::diagnostics::Diagnostic; -use crate::fmt_errors::JSError; use crate::op_error::OpError; use crate::source_maps::get_orig_position; use crate::source_maps::CachedMaps; @@ -14,32 +13,12 @@ pub fn init(i: &mut Isolate, s: &State) { "op_apply_source_map", s.stateful_json_op(op_apply_source_map), ); - i.register_op("op_format_error", s.stateful_json_op(op_format_error)); i.register_op( "op_format_diagnostic", s.stateful_json_op(op_format_diagnostic), ); } -#[derive(Deserialize)] -struct FormatErrorArgs { - error: String, -} - -fn op_format_error( - state: &State, - args: Value, - _zero_copy: Option, -) -> Result { - let args: FormatErrorArgs = serde_json::from_value(args)?; - let error = - JSError::from_json(&args.error, &state.borrow().global_state.ts_compiler); - - Ok(JsonOp::Sync(json!({ - "error": error.to_string(), - }))) -} - #[derive(Deserialize)] struct ApplySourceMap { filename: String, diff --git a/cli/ops/worker_host.rs b/cli/ops/worker_host.rs index 55afd6bf9..0690a3977 100644 --- a/cli/ops/worker_host.rs +++ b/cli/ops/worker_host.rs @@ -215,15 +215,14 @@ fn serialize_worker_event(event: WorkerEvent) -> Value { } }); - if let Ok(err) = error.downcast::() { - let exception: V8Exception = err.into(); + if let Ok(js_error) = error.downcast::() { serialized_error = json!({ "type": "error", "error": { - "message": exception.message, - "fileName": exception.script_resource_name, - "lineNumber": exception.line_number, - "columnNumber": exception.start_column, + "message": js_error.message, + "fileName": js_error.script_resource_name, + "lineNumber": js_error.line_number, + "columnNumber": js_error.start_column, } }); } -- cgit v1.2.3