From a5eb2dfc93afc2899ed6e1ad2b3e029157889f7c Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 22 Jun 2021 07:27:32 +1000 Subject: fix(#10761): graph errors reported as diagnostics for `Deno.emit()` (#10767) Fixes #10761 --- cli/module_graph.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cli/module_graph.rs') diff --git a/cli/module_graph.rs b/cli/module_graph.rs index 8ea8b7f88..e56f26c15 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -1273,6 +1273,18 @@ impl Graph { Ok(()) } + /// Retrieve the first module loading error from the graph and return it. + pub fn get_errors(&self) -> HashMap { + self + .modules + .iter() + .filter_map(|(s, sl)| match sl { + ModuleSlot::Err(err) => Some((s.clone(), err.to_string())), + _ => None, + }) + .collect() + } + /// Retrieve a map that contains a representation of each module in the graph /// which can be used to provide code to a module loader without holding all /// the state to be able to operate on the graph. -- cgit v1.2.3