From 325b752144f997ce4048f2fef970b800fe8cf7c3 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 3 Nov 2021 01:03:42 -0700 Subject: [PATCH] Fix missing fmt argument in error message (#552) * Clean up strange non-multiple-of-4 indentation in Source::with_root * Fix missing fmt argument in error message * Add changelog entry for PR 552 --- CHANGELOG.md | 1 + .../ethers-contract-abigen/src/source.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec383fb7..594bf543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Unreleased +- Improve error message from failure in `ethers_contract_abigen::Source::parse` [#552](https://github.com/gakonst/ethers-rs/pull/552) - use enumerated aliases for overloaded functions [#545](https://github.com/gakonst/ethers-rs/pull/545) - move `AbiEncode` `AbiDecode` trait to ethers-core and implement for core types [#531](https://github.com/gakonst/ethers-rs/pull/531) - add `EthCall` trait and derive macro which generates matching structs for contract calls [#517](https://github.com/gakonst/ethers-rs/pull/517) diff --git a/ethers-contract/ethers-contract-abigen/src/source.rs b/ethers-contract/ethers-contract-abigen/src/source.rs index 78069fae..10695583 100644 --- a/ethers-contract/ethers-contract-abigen/src/source.rs +++ b/ethers-contract/ethers-contract-abigen/src/source.rs @@ -76,19 +76,19 @@ impl Source { P: AsRef, S: AsRef, { + let root = root.as_ref(); cfg_if! { - if #[cfg(target_arch = "wasm32")] { - let root = root.as_ref(); + if #[cfg(target_arch = "wasm32")] { let root = if root.starts_with("/") { - format!("file:://{}", root.display()) + format!("file:://{}", root.display()) } else { format!("{}", root.display()) }; let base = Url::parse(&root) - .map_err(|_| anyhow!("root path '{}' is not absolute"))?; - } else { - let base = Url::from_directory_path(root) - .map_err(|_| anyhow!("root path '{}' is not absolute"))?; + .map_err(|_| anyhow!("root path '{}' is not absolute", root))?; + } else { + let base = Url::from_directory_path(root) + .map_err(|_| anyhow!("root path '{}' is not absolute", root.display()))?; } } let url = base.join(source.as_ref())?;