1#[cfg(feature = "alloc")]
7use alloc::string::String;
8use core::fmt;
9
10#[derive(Debug, Clone, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum Error {
14 InvalidPrivateKey,
16 InvalidHex,
18 #[cfg(feature = "alloc")]
20 Derivation(String),
21 #[cfg(feature = "alloc")]
23 InvalidPath(String),
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::InvalidPrivateKey => write!(f, "invalid private key"),
30 Self::InvalidHex => write!(f, "invalid hex string"),
31 #[cfg(feature = "alloc")]
32 Self::Derivation(msg) => write!(f, "key derivation error: {msg}"),
33 #[cfg(feature = "alloc")]
34 Self::InvalidPath(path) => write!(f, "invalid derivation path: {path}"),
35 }
36 }
37}
38
39#[cfg(feature = "std")]
40impl std::error::Error for Error {}