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 #[cfg(feature = "alloc")]
16 Derivation(String),
17 #[cfg(not(feature = "alloc"))]
19 Derivation,
20 InvalidSeedLength,
22 InvalidHex,
24 Signature,
26}
27
28impl fmt::Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 #[cfg(feature = "alloc")]
32 Self::Derivation(msg) => write!(f, "derivation error: {msg}"),
33 #[cfg(not(feature = "alloc"))]
34 Self::Derivation => write!(f, "derivation error"),
35 Self::InvalidSeedLength => write!(f, "invalid seed length"),
36 Self::InvalidHex => write!(f, "invalid hex string"),
37 Self::Signature => write!(f, "signature error"),
38 }
39 }
40}
41
42#[cfg(feature = "std")]
43impl std::error::Error for Error {}