Skip to content

Commit a8eca3c

Browse files
committed
Merge rust-bitcoin/rust-bitcoin#1049: Implement std::error::Error for ParseAmount
5ce3401 Implement std::error::Error for ParseAmount (Tobin C. Harding) Pull request description: The `ParseAmountError` does not implement `std::error::Error`, must have been missed when we did the rest. Implement `std::error::Error` for `ParseAmount`. ACKs for top commit: Kixunil: ACK 5ce3401 apoelstra: ACK 5ce3401 Tree-SHA512: 8dafc472b7c23b54d856344e786e0f22e8e179f30f6c1011fbf5f8f0c6b1b5d74ed8e4f2638e5f8246f04dbb429e60027db6fe584d51a78957a6e904feb9e8a3
2 parents 023637e + 2835fe1 commit a8eca3c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/util/amount.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,22 @@ impl fmt::Display for ParseAmountError {
185185

186186
#[cfg(feature = "std")]
187187
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
188-
impl std::error::Error for ParseAmountError {}
188+
impl std::error::Error for ParseAmountError {
189+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
190+
use self::ParseAmountError::*;
191+
192+
match *self {
193+
Negative
194+
| TooBig
195+
| TooPrecise
196+
| InvalidFormat
197+
| InputTooLarge
198+
| InvalidCharacter(_)
199+
| UnknownDenomination(_)
200+
| PossiblyConfusingDenomination(_) => None
201+
}
202+
}
203+
}
189204

190205
fn is_too_precise(s: &str, precision: usize) -> bool {
191206
s.contains('.') || precision >= s.len() || s.chars().rev().take(precision).any(|d| d != '0')

0 commit comments

Comments
 (0)