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

fix(ethers-solc): Error instead of panic when checking if the checksum was found #2421

Merged
merged 3 commits into from
May 18, 2023
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
5 changes: 4 additions & 1 deletion ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ impl Solc {
hasher.update(content);
let checksum_calc = &hasher.finalize()[..];

let checksum_found = &RELEASES.0.get_checksum(&version).expect("checksum not found");
let checksum_found = &RELEASES
.0
.get_checksum(&version)
.ok_or_else(|| SolcError::ChecksumNotFound { version: version.clone() })?;

if checksum_calc == checksum_found {
Ok(())
Expand Down
2 changes: 2 additions & 0 deletions ethers-solc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum SolcError {
VersionNotFound,
#[error("Checksum mismatch for {file}: expected {expected} found {detected} for {version}")]
ChecksumMismatch { version: Version, expected: String, detected: String, file: PathBuf },
#[error("Checksum not found for {version}")]
ChecksumNotFound { version: Version },
#[error(transparent)]
SemverError(#[from] semver::Error),
/// Deserialization error
Expand Down