diff options
Diffstat (limited to 'cli/op_error.rs')
-rw-r--r-- | cli/op_error.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/op_error.rs b/cli/op_error.rs index 73f7640a8..3cbe27a06 100644 --- a/cli/op_error.rs +++ b/cli/op_error.rs @@ -15,6 +15,7 @@ //! exceptions. use crate::import_map::ImportMapError; +use crate::swc_util::SwcDiagnosticBuffer; use deno_core::ErrBox; use deno_core::ModuleResolutionError; use rustyline::error::ReadlineError; @@ -382,6 +383,21 @@ impl From<¬ify::Error> for OpError { } } +impl From<SwcDiagnosticBuffer> for OpError { + fn from(error: SwcDiagnosticBuffer) -> Self { + OpError::from(&error) + } +} + +impl From<&SwcDiagnosticBuffer> for OpError { + fn from(error: &SwcDiagnosticBuffer) -> Self { + Self { + kind: ErrorKind::Other, + msg: error.diagnostics.join(", "), + } + } +} + impl From<ErrBox> for OpError { fn from(error: ErrBox) -> Self { #[cfg(unix)] @@ -418,6 +434,11 @@ impl From<ErrBox> for OpError { }) .or_else(|| error.downcast_ref::<dlopen::Error>().map(|e| e.into())) .or_else(|| error.downcast_ref::<notify::Error>().map(|e| e.into())) + .or_else(|| { + error + .downcast_ref::<SwcDiagnosticBuffer>() + .map(|e| e.into()) + }) .or_else(|| unix_error_kind(&error)) .unwrap_or_else(|| { panic!("Can't downcast {:?} to OpError", error); |