chore(solc): improve file not found error (#1611)

This commit is contained in:
Matthias Seitz 2022-08-19 17:36:51 +02:00 committed by GitHub
parent 4f6ccf70b3
commit 6f1d47f3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -32,6 +32,13 @@ pub enum SolcError {
Resolve(SolcIoError),
#[error("File could not be resolved due to broken symlink: {0}.")]
ResolveBadSymlink(SolcIoError),
#[error(
r#"Failed to resolve file: {0}.
--> {1:?}
{2:?}
Check configured remappings."#
)]
FailedResolveImport(SolcIoError, PathBuf, PathBuf),
#[cfg(feature = "svm-solc")]
#[error(transparent)]
SvmError(#[from] svm::SolcVmError),

View File

@ -368,7 +368,20 @@ impl Graph {
&mut resolved_solc_include_paths,
) {
Ok(import) => {
add_node(&mut unresolved, &mut index, &mut resolved_imports, import)?;
add_node(&mut unresolved, &mut index, &mut resolved_imports, import)
.map_err(|err| {
match err {
SolcError::Resolve(err) => {
// make the error more verbose
SolcError::FailedResolveImport(
err,
node.path.clone(),
import_path.clone(),
)
}
_ => err,
}
})?
}
Err(err) => {
unresolved_imports.insert((import_path.to_path_buf(), node.path.clone()));