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