From 1d4b92ac85d8c850270ca859f928404c72c0a49a Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Sun, 21 Apr 2019 18:26:56 -0700 Subject: Add Deno.kill(pid, signo) and process.kill(signo) (Unix only) (#2177) --- cli/errors.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cli/errors.rs') diff --git a/cli/errors.rs b/cli/errors.rs index bd3e7ba73..424091584 100644 --- a/cli/errors.rs +++ b/cli/errors.rs @@ -4,6 +4,8 @@ pub use crate::msg::ErrorKind; use crate::resolve_addr::ResolveAddrError; use deno::JSError; use hyper; +#[cfg(unix)] +use nix::{errno::Errno, Error as UnixError}; use std; use std::fmt; use std::io; @@ -168,6 +170,32 @@ impl From for DenoError { } } +#[cfg(unix)] +impl From for DenoError { + fn from(e: UnixError) -> Self { + match e { + UnixError::Sys(Errno::EPERM) => Self { + repr: Repr::Simple( + ErrorKind::PermissionDenied, + Errno::EPERM.desc().to_owned(), + ), + }, + UnixError::Sys(Errno::EINVAL) => Self { + repr: Repr::Simple( + ErrorKind::InvalidInput, + Errno::EINVAL.desc().to_owned(), + ), + }, + UnixError::Sys(err) => Self { + repr: Repr::Simple(ErrorKind::UnixError, err.desc().to_owned()), + }, + _ => Self { + repr: Repr::Simple(ErrorKind::Other, format!("{}", e)), + }, + } + } +} + pub fn bad_resource() -> DenoError { new(ErrorKind::BadResource, String::from("bad resource id")) } -- cgit v1.2.3