1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
6pub enum VanityError {
7 #[error("File error: {0}")]
8 FileError(#[from] io::Error),
9
10 #[error("Keys and address error: {0}")]
11 KeysAndAddressError(&'static str),
12
13 #[error("Vanity address generator error: {0}")]
14 VanityGeneratorError(&'static str),
15
16 #[error("Fast mode enabled, input is too long!")]
17 FastModeEnabled,
18
19 #[error("Input is not Base58 encoded!")]
20 InputNotBase58,
21
22 #[cfg(feature = "ethereum")]
23 #[error("Input is not Base16 encoded!")]
24 InputNotBase16,
25
26 #[error("Invalid Regex!")]
27 InvalidRegex,
28
29 #[error("Regex is not Base58 encoded!")]
30 RegexNotBase58,
31
32 #[cfg(feature = "ethereum")]
33 #[error("Regex is not Base16 encoded!")]
34 RegexNotBase16,
35
36 #[error("Request too long!")]
37 RequestTooLong,
38
39 #[cfg(feature = "ethereum")]
40 #[error("Case sensitive wallet generation is not supported for Ethereum!")]
41 EthereumCaseSensitiveIsNotSupported,
42
43 #[error("Ethereum support is not enabled. Compile with `--features ethereum`.")]
44 MissingFeatureEthereum,
45
46 #[error("Solana support is not enabled. Compile with `--features solana`.")]
47 MissingFeatureSolana,
48}
49
50impl From<KeysAndAddressError> for VanityError {
51 fn from(keys_and_address_err: KeysAndAddressError) -> Self {
52 VanityError::KeysAndAddressError(keys_and_address_err.0)
53 }
54}
55
56impl From<VanityGeneratorError> for VanityError {
57 fn from(vanity_err: VanityGeneratorError) -> Self {
58 VanityError::VanityGeneratorError(vanity_err.0)
59 }
60}
61
62#[derive(Error, Debug)]
64#[error("Keys and address error: {0}")]
65pub struct KeysAndAddressError(pub &'static str);
66
67#[derive(Error, Debug)]
68#[error("Vanity address generator error: {0}")]
69pub struct VanityGeneratorError(pub &'static str);
70
71impl From<KeysAndAddressError> for VanityGeneratorError {
72 fn from(keys_and_address_err: KeysAndAddressError) -> Self {
73 VanityGeneratorError(keys_and_address_err.0)
74 }
75}