diff options
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cli/main.rs b/cli/main.rs index 23f073a7d..1fb942963 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1060,16 +1060,22 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T { match result { Ok(value) => value, Err(error) => { - let error_string = match error.downcast_ref::<JsError>() { - Some(e) => format_js_error(e), - None => format!("{:?}", error), - }; + let mut error_string = format!("{:?}", error); + let mut error_code = 1; + + if let Some(e) = error.downcast_ref::<JsError>() { + error_string = format_js_error(e); + } else if let Some(e) = error.downcast_ref::<lockfile::LockfileError>() { + error_string = e.to_string(); + error_code = 10; + } + eprintln!( "{}: {}", colors::red_bold("error"), error_string.trim_start_matches("error: ") ); - std::process::exit(1); + std::process::exit(error_code); } } } |