Skip to main content

kobe_eth/
error.rs

1//! Error types for Ethereum wallet operations.
2
3#[cfg(feature = "alloc")]
4use alloc::string::String;
5
6use core::fmt;
7
8/// Errors that can occur during Ethereum wallet operations.
9#[derive(Debug)]
10pub enum Error {
11    /// Invalid private key.
12    InvalidPrivateKey,
13    /// Key derivation error.
14    #[cfg(feature = "alloc")]
15    Derivation(String),
16}
17
18impl fmt::Display for Error {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            Self::InvalidPrivateKey => write!(f, "invalid private key"),
22            #[cfg(feature = "alloc")]
23            Self::Derivation(msg) => write!(f, "key derivation error: {msg}"),
24        }
25    }
26}
27
28#[cfg(feature = "std")]
29impl std::error::Error for Error {}