Skip to content

Commit

Permalink
feat: more user-friendly error when no compiler is available (#185)
Browse files Browse the repository at this point in the history
Currently, if no Vyper or Solidity compiler is available, returned error
would look like:
```
Found incompatible Solidity versions:
src/a.vy  imports:
    src/b.vy 
Found incompatible Solidity versions:
src/b.vy  imports:
...
```

This PR adds logic for catching case when the error is caused by missing
compiler for the language
  • Loading branch information
klkvr committed Aug 4, 2024
1 parent c40158d commit ec205aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/compilers/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,12 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
compiler.available_versions(&language)
};

if all_versions.is_empty() && !nodes.is_empty() {
return Err(SolcError::msg(format!(
"Found {language} sources, but no compiler versions are available for it"
)));
}

// stores all versions and their nodes that can be compiled
let mut versioned_nodes = HashMap::new();

Expand All @@ -656,7 +662,7 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
} else {
let mut msg = String::new();
self.format_imports_list(idx, &mut msg).unwrap();
errors.push(format!("Found incompatible Solidity versions:\n{msg}"));
errors.push(format!("Found incompatible versions:\n{msg}"));
}

erroneous_nodes.insert(idx);
Expand Down

0 comments on commit ec205aa

Please sign in to comment.