diff options
Diffstat (limited to 'cli/ops/dispatch_json.rs')
-rw-r--r-- | cli/ops/dispatch_json.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cli/ops/dispatch_json.rs b/cli/ops/dispatch_json.rs index 2cb3a8400..70498eb8f 100644 --- a/cli/ops/dispatch_json.rs +++ b/cli/ops/dispatch_json.rs @@ -1,4 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use crate::op_error::OpError; use deno_core::*; use futures::future::FutureExt; pub use serde_derive::Deserialize; @@ -7,7 +8,7 @@ pub use serde_json::Value; use std::future::Future; use std::pin::Pin; -pub type JsonResult = Result<Value, ErrBox>; +pub type JsonResult = Result<Value, OpError>; pub type AsyncJsonOp = Pin<Box<dyn Future<Output = JsonResult>>>; @@ -19,11 +20,10 @@ pub enum JsonOp { AsyncUnref(AsyncJsonOp), } -fn json_err(err: ErrBox) -> Value { - use crate::deno_error::GetErrorKind; +fn json_err(err: OpError) -> Value { json!({ - "message": err.to_string(), - "kind": err.kind() as u32, + "message": err.msg, + "kind": err.kind as u32, }) } @@ -43,13 +43,13 @@ struct AsyncArgs { pub fn json_op<D>(d: D) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp where - D: Fn(Value, Option<ZeroCopyBuf>) -> Result<JsonOp, ErrBox>, + D: Fn(Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>, { move |control: &[u8], zero_copy: Option<ZeroCopyBuf>| { let async_args: AsyncArgs = match serde_json::from_slice(control) { Ok(args) => args, Err(e) => { - let buf = serialize_result(None, Err(ErrBox::from(e))); + let buf = serialize_result(None, Err(OpError::from(e))); return CoreOp::Sync(buf); } }; @@ -57,7 +57,7 @@ where let is_sync = promise_id.is_none(); let result = serde_json::from_slice(control) - .map_err(ErrBox::from) + .map_err(OpError::from) .and_then(|args| d(args, zero_copy)); // Convert to CoreOp @@ -92,7 +92,7 @@ where } } -pub fn blocking_json<F>(is_sync: bool, f: F) -> Result<JsonOp, ErrBox> +pub fn blocking_json<F>(is_sync: bool, f: F) -> Result<JsonOp, OpError> where F: 'static + Send + FnOnce() -> JsonResult, { |