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