summaryrefslogtreecommitdiff
path: root/cli/module_graph.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-06-22 07:27:32 +1000
committerGitHub <noreply@github.com>2021-06-22 07:27:32 +1000
commita5eb2dfc93afc2899ed6e1ad2b3e029157889f7c (patch)
tree5fb4abf918304fa13e961cc791c7b43b26367d7c /cli/module_graph.rs
parent281c4cd8fcf5fd54f558a6922736def2c7804529 (diff)
fix(#10761): graph errors reported as diagnostics for `Deno.emit()` (#10767)
Fixes #10761
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r--cli/module_graph.rs12
1 files changed, 12 insertions, 0 deletions
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<ModuleSpecifier, String> {
+ 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.