Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

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

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ethers-solc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
15 changes: 14 additions & 1 deletion ethers-solc/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down