Skip to content

Commit

Permalink
avoid errors in computing issue details (vercel/turborepo#4817)
Browse files Browse the repository at this point in the history
### Description

Better error message when import mapping fails
  • Loading branch information
sokra authored May 4, 2023
1 parent 0dc7511 commit 2fdb8a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/turbopack-core/src/issue/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use turbo_tasks_fs::FileSystemPathVc;

use super::{Issue, IssueVc};
use crate::{
error::PrettyPrintError,
issue::{IssueSeverityVc, OptionIssueSourceVc},
resolve::{options::ResolveOptionsVc, parse::RequestVc},
};
Expand Down Expand Up @@ -82,7 +83,16 @@ impl Issue for ResolvingIssue {
if let Some(import_map) = &self.resolve_options.await?.import_map {
let result = import_map.lookup(self.context, self.request);

writeln!(detail, "Import map: {}", result.to_string().await?)?;
match result.to_string().await {
Ok(str) => writeln!(detail, "Import map: {}", str)?,
Err(err) => {
writeln!(
detail,
"Error while looking up import map: {}",
PrettyPrintError(&err)
)?;
}
}
}
Ok(StringVc::cell(detail))
}
Expand Down

0 comments on commit 2fdb8a9

Please sign in to comment.