diff options
Diffstat (limited to 'cli/diagnostics.rs')
-rw-r--r-- | cli/diagnostics.rs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index b7327d72c..695330af3 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -6,7 +6,9 @@ use deno_core::serde::Deserialize; use deno_core::serde::Deserializer; use deno_core::serde::Serialize; use deno_core::serde::Serializer; +use deno_core::ModuleSpecifier; use regex::Regex; +use std::collections::HashMap; use std::error::Error; use std::fmt; @@ -233,13 +235,14 @@ impl Diagnostic { _ => "", }; + let code = if self.code >= 900001 { + "".to_string() + } else { + colors::bold(format!("TS{} ", self.code)).to_string() + }; + if !category.is_empty() { - write!( - f, - "{} [{}]: ", - colors::bold(&format!("TS{}", self.code)), - category - ) + write!(f, "{}[{}]: ", code, category) } else { Ok(()) } @@ -359,6 +362,24 @@ impl Diagnostics { Diagnostics(diagnostics) } + pub fn extend_graph_errors( + &mut self, + errors: HashMap<ModuleSpecifier, String>, + ) { + self.0.extend(errors.into_iter().map(|(s, e)| Diagnostic { + category: DiagnosticCategory::Error, + code: 900001, + start: None, + end: None, + message_text: Some(e), + message_chain: None, + source: None, + source_line: None, + file_name: Some(s.to_string()), + related_information: None, + })); + } + pub fn is_empty(&self) -> bool { self.0.is_empty() } |