Skip to content

Commit 0a0b841

Browse files
author
Hugh Cunningham
committed
adds error formatting for IronfishFrostError if std is enabled
allows us to display error details in ironfish repo enables std for reddsa dependency if std is enabled
1 parent 26012b0 commit 0a0b841

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ rand = "0.8.5"
2626
[features]
2727
default = ["signing"]
2828

29-
std = []
29+
std = ["reddsa/std"]
3030
signing = ["dep:blake3", "dep:rand_chacha", "std"]
3131
dkg = []

src/error.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,41 @@ impl From<ed25519_dalek::SignatureError> for IronfishFrostError {
3636
IronfishFrostError::SignatureError(error)
3737
}
3838
}
39+
40+
#[cfg(feature = "std")]
41+
use std::fmt;
42+
43+
#[cfg(feature = "std")]
44+
impl fmt::Display for IronfishFrostError {
45+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
46+
match self {
47+
Self::InvalidInput => {
48+
write!(f, "invalid input")?;
49+
Ok(())
50+
}
51+
Self::StdError => {
52+
write!(f, "std error")?;
53+
Ok(())
54+
}
55+
Self::FrostError(e) => {
56+
write!(f, "frost error: ")?;
57+
e.fmt(f)
58+
}
59+
Self::IoError(e) => {
60+
write!(f, "io error: ")?;
61+
e.fmt(f)
62+
}
63+
Self::SignatureError(e) => {
64+
write!(f, "signature rror: ")?;
65+
e.fmt(f)
66+
}
67+
Self::ChecksumError(e) => {
68+
write!(f, "checksum error: ")?;
69+
e.fmt(f)
70+
}
71+
}
72+
}
73+
}
74+
75+
#[cfg(feature = "std")]
76+
impl std::error::Error for IronfishFrostError {}

0 commit comments

Comments
 (0)