fix(#10761): graph errors reported as diagnostics for Deno.emit() (#10767)

Fixes #10761
This commit is contained in:
Kitson Kelly 2021-06-22 07:27:32 +10:00 committed by GitHub
parent 281c4cd8fc
commit a5eb2dfc93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 7 deletions

View file

@ -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.