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

Commit 6f1d47f

Browse files
authored
chore(solc): improve file not found error (#1611)
1 parent 4f6ccf7 commit 6f1d47f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: ethers-solc/src/error.rs

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ pub enum SolcError {
3232
Resolve(SolcIoError),
3333
#[error("File could not be resolved due to broken symlink: {0}.")]
3434
ResolveBadSymlink(SolcIoError),
35+
#[error(
36+
r#"Failed to resolve file: {0}.
37+
--> {1:?}
38+
{2:?}
39+
Check configured remappings."#
40+
)]
41+
FailedResolveImport(SolcIoError, PathBuf, PathBuf),
3542
#[cfg(feature = "svm-solc")]
3643
#[error(transparent)]
3744
SvmError(#[from] svm::SolcVmError),

Diff for: ethers-solc/src/resolver/mod.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,20 @@ impl Graph {
368368
&mut resolved_solc_include_paths,
369369
) {
370370
Ok(import) => {
371-
add_node(&mut unresolved, &mut index, &mut resolved_imports, import)?;
371+
add_node(&mut unresolved, &mut index, &mut resolved_imports, import)
372+
.map_err(|err| {
373+
match err {
374+
SolcError::Resolve(err) => {
375+
// make the error more verbose
376+
SolcError::FailedResolveImport(
377+
err,
378+
node.path.clone(),
379+
import_path.clone(),
380+
)
381+
}
382+
_ => err,
383+
}
384+
})?
372385
}
373386
Err(err) => {
374387
unresolved_imports.insert((import_path.to_path_buf(), node.path.clone()));

0 commit comments

Comments
 (0)