Skip to main content

kobe_sol/
error.rs

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