diff options
Diffstat (limited to 'cli/ops/worker_host.rs')
-rw-r--r-- | cli/ops/worker_host.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/cli/ops/worker_host.rs b/cli/ops/worker_host.rs index c3b907673..910f44459 100644 --- a/cli/ops/worker_host.rs +++ b/cli/ops/worker_host.rs @@ -1,10 +1,9 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use super::dispatch_json::{Deserialize, JsonOp, Value}; -use crate::deno_error::DenoError; -use crate::deno_error::ErrorKind; use crate::fmt_errors::JSError; use crate::futures::SinkExt; use crate::global_state::GlobalState; +use crate::op_error::OpError; use crate::ops::json_op; use crate::permissions::DenoPermissions; use crate::startup_data; @@ -147,7 +146,7 @@ fn op_create_worker( state: &State, args: Value, _data: Option<ZeroCopyBuf>, -) -> Result<JsonOp, ErrBox> { +) -> Result<JsonOp, OpError> { let args: CreateWorkerArgs = serde_json::from_value(args)?; let specifier = args.specifier.clone(); @@ -175,7 +174,8 @@ fn op_create_worker( module_specifier, has_source_code, source_code, - )?; + ) + .map_err(|e| OpError::other(e.to_string()))?; // At this point all interactions with worker happen using thread // safe handler returned from previous function call let mut parent_state = parent_state.borrow_mut(); @@ -197,7 +197,7 @@ fn op_host_terminate_worker( state: &State, args: Value, _data: Option<ZeroCopyBuf>, -) -> Result<JsonOp, ErrBox> { +) -> Result<JsonOp, OpError> { let args: WorkerArgs = serde_json::from_value(args)?; let id = args.id as u32; let mut state = state.borrow_mut(); @@ -242,7 +242,7 @@ fn op_host_get_message( state: &State, args: Value, _data: Option<ZeroCopyBuf>, -) -> Result<JsonOp, ErrBox> { +) -> Result<JsonOp, OpError> { let args: WorkerArgs = serde_json::from_value(args)?; let id = args.id as u32; let worker_handle = { @@ -274,7 +274,7 @@ fn op_host_post_message( state: &State, args: Value, data: Option<ZeroCopyBuf>, -) -> Result<JsonOp, ErrBox> { +) -> Result<JsonOp, OpError> { let args: WorkerArgs = serde_json::from_value(args)?; let id = args.id as u32; let msg = Vec::from(data.unwrap().as_ref()).into_boxed_slice(); @@ -285,7 +285,7 @@ fn op_host_post_message( state.workers.get(&id).expect("No worker handle found"); let fut = worker_handle .post_message(msg) - .map_err(|e| DenoError::new(ErrorKind::Other, e.to_string())); + .map_err(|e| OpError::other(e.to_string())); futures::executor::block_on(fut)?; Ok(JsonOp::Sync(json!({}))) } |