diff options
author | 2shiori17 <98276492+2shiori17@users.noreply.github.com> | 2022-07-14 05:01:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 22:01:09 +0200 |
commit | 0aca3f06904d2582b4f520e0b03b56bb2255c03e (patch) | |
tree | 0e493cb1593ffe07740514951cf3d264170f83f4 /cli/file_watcher.rs | |
parent | 5273259eef712a04224c8a3db96d3dc824e7bb86 (diff) |
fix(cli): Improve error message in watch mode (#15184)
Diffstat (limited to 'cli/file_watcher.rs')
-rw-r--r-- | cli/file_watcher.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs index 36b4276e7..60627548e 100644 --- a/cli/file_watcher.rs +++ b/cli/file_watcher.rs @@ -1,9 +1,11 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::colors; +use crate::fmt_errors::format_js_error; use crate::fs_util::canonicalize_path; use deno_core::error::AnyError; +use deno_core::error::JsError; use deno_core::futures::Future; use log::info; use notify::event::Event as NotifyEvent; @@ -71,8 +73,15 @@ where { let result = watch_future.await; if let Err(err) = result { - let msg = format!("{}: {}", colors::red_bold("error"), err); - eprintln!("{}", msg); + let error_string = match err.downcast_ref::<JsError>() { + Some(e) => format_js_error(e), + None => format!("{:?}", err), + }; + eprintln!( + "{}: {}", + colors::red_bold("error"), + error_string.trim_start_matches("error: ") + ); } } |