summaryrefslogtreecommitdiff
path: root/cli/op_error.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-03-24 20:50:51 -0700
committerGitHub <noreply@github.com>2020-03-24 23:50:51 -0400
commitaddfdc4cd0ffa0e0f6b284379c8873a202af7d5b (patch)
tree97a2a03904b009848be4ea0f16e3941d0948965c /cli/op_error.rs
parent07fc95aceee950316500cf2d770317b6e993356e (diff)
fix: add fsEvent notify::Error casts (#4488)
Diffstat (limited to 'cli/op_error.rs')
-rw-r--r--cli/op_error.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/op_error.rs b/cli/op_error.rs
index bebfd2e72..3537d4b28 100644
--- a/cli/op_error.rs
+++ b/cli/op_error.rs
@@ -18,6 +18,7 @@ use crate::import_map::ImportMapError;
use deno_core::ErrBox;
use deno_core::ModuleResolutionError;
use dlopen;
+use notify;
use reqwest;
use rustyline::error::ReadlineError;
use std;
@@ -349,6 +350,30 @@ impl From<&dlopen::Error> for OpError {
}
}
+impl From<notify::Error> for OpError {
+ fn from(error: notify::Error) -> Self {
+ OpError::from(&error)
+ }
+}
+
+impl From<&notify::Error> for OpError {
+ fn from(error: &notify::Error) -> Self {
+ use notify::ErrorKind::*;
+ let kind = match error.kind {
+ Generic(_) => ErrorKind::Other,
+ Io(ref e) => return e.into(),
+ PathNotFound => ErrorKind::NotFound,
+ WatchNotFound => ErrorKind::NotFound,
+ InvalidConfig(_) => ErrorKind::InvalidData,
+ };
+
+ Self {
+ kind,
+ msg: error.to_string(),
+ }
+ }
+}
+
impl From<ErrBox> for OpError {
fn from(error: ErrBox) -> Self {
#[cfg(unix)]
@@ -384,6 +409,7 @@ impl From<ErrBox> for OpError {
.map(|e| e.into())
})
.or_else(|| error.downcast_ref::<dlopen::Error>().map(|e| e.into()))
+ .or_else(|| error.downcast_ref::<notify::Error>().map(|e| e.into()))
.or_else(|| unix_error_kind(&error))
.unwrap_or_else(|| {
panic!("Can't downcast {:?} to OpError", error);