diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-08-26 00:22:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 00:22:15 +0200 |
commit | 9bfb0df805719cb3f022a5b5d9f9d898ae954c2e (patch) | |
tree | 6c7d62d95fcbde54ebbe1035bdc74618c63cfbc0 /cli/ops/process.rs | |
parent | d0ccab7fb7dd80030d3765ca9a9af44de6ecda5a (diff) |
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/ops/process.rs')
-rw-r--r-- | cli/ops/process.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/cli/ops/process.rs b/cli/ops/process.rs index bf733a78e..1754812a2 100644 --- a/cli/ops/process.rs +++ b/cli/ops/process.rs @@ -1,17 +1,15 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use super::dispatch_json::{Deserialize, JsonOp, Value}; use super::io::{std_file_resource, StreamResource, StreamResourceHolder}; -use crate::op_error::OpError; use crate::signal::kill; use crate::state::State; use deno_core::CoreIsolate; use deno_core::CoreIsolateState; +use deno_core::ErrBox; use deno_core::ResourceTable; use deno_core::ZeroCopyBuf; use futures::future::poll_fn; use futures::future::FutureExt; -use futures::TryFutureExt; -use std::convert::From; use std::rc::Rc; use tokio::process::Command; @@ -27,19 +25,19 @@ pub fn init(i: &mut CoreIsolate, s: &Rc<State>) { fn clone_file( rid: u32, resource_table: &mut ResourceTable, -) -> Result<std::fs::File, OpError> { +) -> Result<std::fs::File, ErrBox> { std_file_resource(resource_table, rid, move |r| match r { - Ok(std_file) => std_file.try_clone().map_err(OpError::from), - Err(_) => Err(OpError::bad_resource_id()), + Ok(std_file) => std_file.try_clone().map_err(ErrBox::from), + Err(_) => Err(ErrBox::bad_resource_id()), }) } -fn subprocess_stdio_map(s: &str) -> Result<std::process::Stdio, OpError> { +fn subprocess_stdio_map(s: &str) -> Result<std::process::Stdio, ErrBox> { match s { "inherit" => Ok(std::process::Stdio::inherit()), "piped" => Ok(std::process::Stdio::piped()), "null" => Ok(std::process::Stdio::null()), - _ => Err(OpError::other("Invalid resource for stdio".to_string())), + _ => Err(ErrBox::type_error("Invalid resource for stdio")), } } @@ -66,7 +64,7 @@ fn op_run( state: &Rc<State>, args: Value, _zero_copy: &mut [ZeroCopyBuf], -) -> Result<JsonOp, OpError> { +) -> Result<JsonOp, ErrBox> { let run_args: RunArgs = serde_json::from_value(args)?; state.check_run()?; @@ -177,7 +175,7 @@ fn op_run_status( state: &Rc<State>, args: Value, _zero_copy: &mut [ZeroCopyBuf], -) -> Result<JsonOp, OpError> { +) -> Result<JsonOp, ErrBox> { let args: RunStatusArgs = serde_json::from_value(args)?; let rid = args.rid as u32; @@ -189,9 +187,9 @@ fn op_run_status( let mut resource_table = resource_table.borrow_mut(); let child_resource = resource_table .get_mut::<ChildResource>(rid) - .ok_or_else(OpError::bad_resource_id)?; + .ok_or_else(ErrBox::bad_resource_id)?; let child = &mut child_resource.child; - child.map_err(OpError::from).poll_unpin(cx) + child.poll_unpin(cx).map_err(ErrBox::from) }) .await?; @@ -227,7 +225,7 @@ fn op_kill( state: &Rc<State>, args: Value, _zero_copy: &mut [ZeroCopyBuf], -) -> Result<JsonOp, OpError> { +) -> Result<JsonOp, ErrBox> { state.check_unstable("Deno.kill"); state.check_run()?; |