summaryrefslogtreecommitdiff
path: root/cli/module_graph.rs
diff options
context:
space:
mode:
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.