From d09845e0c5cc49de732f06f27161308dfb5c3e1a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 20 Jun 2022 19:52:16 +0200 Subject: [PATCH] chore(solc): improve checksum error message (#1394) --- ethers-solc/src/compile/mod.rs | 6 ++++-- ethers-solc/src/error.rs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index 070b2b2a..b57b1c37 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -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 }) } } diff --git a/ethers-solc/src/error.rs b/ethers-solc/src/error.rs index 015c4c12..edfd4e89 100644 --- a/ethers-solc/src/error.rs +++ b/ethers-solc/src/error.rs @@ -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