#[cfg(feature = "alloc")]
use alloc::{string::String, vec::Vec};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("invalid mnemonic: {0}")]
Mnemonic(#[cfg_attr(feature = "std", from)] bip39::Error),
#[error("invalid word count {0}, must be 12, 15, 18, 21, or 24")]
InvalidWordCount(usize),
#[cfg(feature = "camouflage")]
#[error("password must not be empty")]
EmptyPassword,
#[cfg(feature = "camouflage")]
#[error("PBKDF2 key derivation failed")]
KeyDerivation,
#[cfg(feature = "alloc")]
#[error("prefix \"{prefix}\" is too short (minimum {min_len} characters)")]
PrefixTooShort {
prefix: String,
min_len: usize,
},
#[cfg(feature = "alloc")]
#[error("prefix \"{0}\" does not match any BIP-39 word")]
UnknownPrefix(String),
#[cfg(feature = "alloc")]
#[error("prefix \"{prefix}\" is ambiguous, matches: {}", candidates.join(", "))]
AmbiguousPrefix {
prefix: String,
candidates: Vec<String>,
},
#[error("index overflow")]
IndexOverflow,
#[cfg(feature = "slip10")]
#[error("SLIP-10: invalid seed length")]
Slip10InvalidSeed,
#[cfg(feature = "slip10")]
#[error("SLIP-10: {0}")]
Slip10InvalidPath(String),
#[cfg(feature = "bip32")]
#[error("BIP-32: {0}")]
Bip32Derivation(String),
}
#[cfg(not(feature = "std"))]
impl From<bip39::Error> for Error {
fn from(e: bip39::Error) -> Self {
Self::Mnemonic(e)
}
}