From 6f6b05937ee4c0d85768bc8fafb9ec8648b7cfce Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Fri, 23 Dec 2022 11:35:15 +0100 Subject: [PATCH] Name fields of error variants (#1462) * Name fields of error variants * Changelog --- client/CHANGELOG.md | 4 ++++ client/src/api/address.rs | 8 ++++---- client/src/error.rs | 9 +++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/CHANGELOG.md b/client/CHANGELOG.md index b97334d9f..0b827962c 100644 --- a/client/CHANGELOG.md +++ b/client/CHANGELOG.md @@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `TrackedParticipation::answers` field; +### Changed + +- Fields of `Error::InputAddressNotFound` are now named; + ## 2.0.1-rc.5 - 2022-12-20 ### Added diff --git a/client/src/api/address.rs b/client/src/api/address.rs index d668c676a..6d4320a18 100644 --- a/client/src/api/address.rs +++ b/client/src/api/address.rs @@ -245,8 +245,8 @@ pub async fn search_address( return Ok((range.start + index as u32, true)); } } - Err(crate::error::Error::InputAddressNotFound( - address.to_bech32(bech32_hrp), - format!("{range:?}"), - )) + Err(crate::error::Error::InputAddressNotFound { + address: address.to_bech32(bech32_hrp), + range: format!("{range:?}"), + }) } diff --git a/client/src/error.rs b/client/src/error.rs index ec52190ba..9772c3a94 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -42,8 +42,13 @@ pub enum Error { #[serde(serialize_with = "display_string")] CryptoError(#[from] crypto::Error), /// Address not found - #[error("address: {0} not found in range: {1}")] - InputAddressNotFound(String, String), + #[error("address: {address} not found in range: {range}")] + InputAddressNotFound { + /// The address that was not found. + address: String, + /// The range in which the address was not found. + range: String, + }, /// Invalid amount in API response #[error("invalid amount in API response: {0}")] InvalidAmount(String),