1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Errors generated by the address library.
use thiserror::Error;

/// Error thrown by the address library.
#[derive(Debug, Error)]
pub enum Error {
    /// Error generated when an address has the wrong prefix.
    #[error("address must begin with 0x")]
    BadAddressPrefix,

    /// Error generated converting to fixed length slice.
    #[error(transparent)]
    TryFromSlice(#[from] std::array::TryFromSliceError),

    /// Error generated by the ECDSA library.
    #[cfg(feature = "ethereum")]
    #[error(transparent)]
    Ecdsa(#[from] k256::ecdsa::Error),

    /// Error generated by elliptic curve library.
    #[cfg(feature = "ethereum")]
    #[error(transparent)]
    Elliptic(#[from] k256::elliptic_curve::Error),

    /// Error generated parsing from hex.
    #[cfg(feature = "ethereum")]
    #[error(transparent)]
    Hex(#[from] hex::FromHexError),
}