winterwallet_client/
error.rs1#[derive(Debug)]
3pub enum Error {
4 InvalidAccountData,
6
7 Winternitz(winterwallet_core::WinternitzError),
9
10 RootMismatch,
12
13 SignerPositionMismatch {
15 expected: (u32, u32, u32),
17 actual: (u32, u32, u32),
19 },
20
21 PositionOverflow,
23
24 PayloadTooLarge(&'static str),
26
27 TransactionTooLarge { estimated: usize, limit: usize },
29
30 UnsupportedTransaction(&'static str),
32}
33
34impl core::fmt::Display for Error {
35 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
36 match self {
37 Self::InvalidAccountData => write!(f, "invalid account data"),
38 Self::Winternitz(e) => write!(f, "winternitz error: {e}"),
39 Self::RootMismatch => write!(f, "on-chain root does not match local state"),
40 Self::SignerPositionMismatch { expected, actual } => write!(
41 f,
42 "signer position mismatch: expected ({}, {}, {}), got ({}, {}, {})",
43 expected.0, expected.1, expected.2, actual.0, actual.1, actual.2
44 ),
45 Self::PositionOverflow => write!(f, "signing position overflow"),
46 Self::PayloadTooLarge(reason) => write!(f, "payload too large: {reason}"),
47 Self::TransactionTooLarge { estimated, limit } => {
48 write!(
49 f,
50 "transaction too large: {estimated} bytes (limit {limit})"
51 )
52 }
53 Self::UnsupportedTransaction(reason) => write!(f, "unsupported transaction: {reason}"),
54 }
55 }
56}
57
58impl std::error::Error for Error {
59 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
60 match self {
61 Self::Winternitz(e) => Some(e),
62 _ => None,
63 }
64 }
65}
66
67impl From<winterwallet_core::WinternitzError> for Error {
68 fn from(e: winterwallet_core::WinternitzError) -> Self {
69 Self::Winternitz(e)
70 }
71}