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/signal.rs | |
parent | d0ccab7fb7dd80030d3765ca9a9af44de6ecda5a (diff) |
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/signal.rs')
-rw-r--r-- | cli/signal.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cli/signal.rs b/cli/signal.rs index f74f9ab26..fcc70d00e 100644 --- a/cli/signal.rs +++ b/cli/signal.rs @@ -1,5 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::op_error::OpError; +use deno_core::ErrBox; #[cfg(not(unix))] const SIGINT: i32 = 2; @@ -19,37 +19,37 @@ use winapi::{ }; #[cfg(unix)] -pub fn kill(pid: i32, signo: i32) -> Result<(), OpError> { +pub fn kill(pid: i32, signo: i32) -> Result<(), ErrBox> { use nix::sys::signal::{kill as unix_kill, Signal}; use nix::unistd::Pid; use std::convert::TryFrom; let sig = Signal::try_from(signo)?; - unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(OpError::from) + unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(ErrBox::from) } #[cfg(not(unix))] -pub fn kill(pid: i32, signal: i32) -> Result<(), OpError> { +pub fn kill(pid: i32, signal: i32) -> Result<(), ErrBox> { match signal { SIGINT | SIGKILL | SIGTERM => { if pid <= 0 { - return Err(OpError::type_error("unsupported pid".to_string())); + return Err(ErrBox::type_error("unsupported pid")); } unsafe { let handle = OpenProcess(PROCESS_TERMINATE, 0, pid as DWORD); if handle.is_null() { - return Err(OpError::from(std::io::Error::last_os_error())); + return Err(ErrBox::last_os_error()); } if TerminateProcess(handle, 1) == 0 { CloseHandle(handle); - return Err(OpError::from(std::io::Error::last_os_error())); + return Err(ErrBox::last_os_error()); } if CloseHandle(handle) == 0 { - return Err(OpError::from(std::io::Error::last_os_error())); + return Err(ErrBox::last_os_error()); } } } _ => { - return Err(OpError::type_error("unsupported signal".to_string())); + return Err(ErrBox::type_error("unsupported signal".to_string())); } } Ok(()) |