chore(solc): improve checksum error message (#1394)

This commit is contained in:
Matthias Seitz 2022-06-20 19:52:16 +02:00 committed by GitHub
parent e262e5d758
commit d09845e0c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -457,8 +457,10 @@ impl Solc {
if checksum_calc == checksum_found {
Ok(())
} else {
tracing:: warn!(target : "solc", "checksum mismatch for {:?}, expected {}, but found {} for file {:?}", version, hex::encode(&checksum_found), hex::encode(checksum_calc), version_path);
Err(SolcError::ChecksumMismatch)
let expected = hex::encode(&checksum_found);
let detected = hex::encode(checksum_calc);
tracing:: warn!(target : "solc", "checksum mismatch for {:?}, expected {}, but found {} for file {:?}", version, expected, detected, version_path);
Err(SolcError::ChecksumMismatch { version, expected, detected, file: version_path })
}
}

View File

@ -1,3 +1,4 @@
use semver::Version;
use std::{io, path::PathBuf};
use thiserror::Error;
@ -13,8 +14,8 @@ pub enum SolcError {
PragmaNotFound,
#[error("Could not find solc version locally or upstream")]
VersionNotFound,
#[error("Checksum mismatch")]
ChecksumMismatch,
#[error("Checksum mismatch for {file}: expected {expected} found {detected} for {version}")]
ChecksumMismatch { version: Version, expected: String, detected: String, file: PathBuf },
#[error(transparent)]
SemverError(#[from] semver::Error),
/// Deserialization error