From b2036a4db71afd67a78f932528143fb07faea538 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 16 Nov 2021 09:02:28 -0500 Subject: refactor: re-export anyhow from deno_core (#12777) --- core/ops_json.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'core/ops_json.rs') diff --git a/core/ops_json.rs b/core/ops_json.rs index a2eff40ef..b3153763e 100644 --- a/core/ops_json.rs +++ b/core/ops_json.rs @@ -1,11 +1,11 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use crate::error::AnyError; use crate::ops::OpCall; use crate::serialize_op_result; use crate::Op; use crate::OpFn; use crate::OpState; +use anyhow::Error; use serde::de::DeserializeOwned; use serde::Serialize; use std::cell::RefCell; @@ -51,7 +51,7 @@ pub fn void_op_async() -> Box { /// A more complete example is available in the examples directory. pub fn op_sync(op_fn: F) -> Box where - F: Fn(&mut OpState, A, B) -> Result + 'static, + F: Fn(&mut OpState, A, B) -> Result + 'static, A: DeserializeOwned, B: DeserializeOwned, R: Serialize + 'static, @@ -96,7 +96,7 @@ where F: Fn(Rc>, A, B) -> R + 'static, A: DeserializeOwned, B: DeserializeOwned, - R: Future> + 'static, + R: Future> + 'static, RV: Serialize + 'static, { Box::new(move |state, payload| -> Op { @@ -106,7 +106,7 @@ where let args = match payload.deserialize() { Ok(args) => args, Err(err) => { - return Op::Sync(serialize_op_result(Err::<(), AnyError>(err), state)) + return Op::Sync(serialize_op_result(Err::<(), Error>(err), state)) } }; let (a, b) = args; @@ -128,7 +128,7 @@ where F: Fn(Rc>, A, B) -> R + 'static, A: DeserializeOwned, B: DeserializeOwned, - R: Future> + 'static, + R: Future> + 'static, RV: Serialize + 'static, { Box::new(move |state, payload| -> Op { @@ -138,7 +138,7 @@ where let args = match payload.deserialize() { Ok(args) => args, Err(err) => { - return Op::Sync(serialize_op_result(Err::<(), AnyError>(err), state)) + return Op::Sync(serialize_op_result(Err::<(), Error>(err), state)) } }; let (a, b) = args; @@ -162,7 +162,7 @@ mod tests { _state: Rc>, msg: Option, _: (), - ) -> Result<(), AnyError> { + ) -> Result<(), Error> { assert_eq!(msg.unwrap(), "hello"); Err(crate::error::generic_error("foo")) } -- cgit v1.2.3