1pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error)]
10#[allow(clippy::large_enum_variant)]
12pub enum Error {
13 #[error("Error when building indexation message: {0}")]
15 IndexationError(String),
16 #[error("Error when building transaction message")]
18 TransactionError,
19 #[error("The wallet account doesn't have enough balance. It only has {0}, required is {1}")]
21 NotEnoughBalance(u64, u64),
22 #[error(
24 "The wallet account has enough funds, but splitted on too many outputs: {0}, max. is 127, consolidate them"
25 )]
26 ConsolidationRequired(usize),
27 #[error("Dust error: {0}")]
29 DustError(String),
30 #[error("Must provide required parameter: {0}")]
32 MissingParameter(&'static str),
33 #[error("Parameter is invalid:{0}")]
35 InvalidParameter(&'static str),
36 #[error("No synced node available")]
38 SyncedNodePoolEmpty,
39 #[error("Failed to parse node_pool_urls")]
41 NodePoolUrlsError,
42 #[error("Failed to reach quorum {0} {1}")]
44 QuorumThresholdError(usize, usize),
45 #[error("Not enough nodes for quorum {0} {1}")]
47 QuorumPoolSizeError(usize, usize),
48 #[error("Node error: {0}")]
50 NodeError(String),
51 #[error("Failed to read node RwLock")]
53 NodeReadError,
54 #[error("{0}")]
56 FromHexError(#[from] hex::FromHexError),
57 #[error("{0}")]
59 MessageError(#[from] bee_message::Error),
60 #[error("{0}")]
62 BeeRestApiError(#[from] bee_rest_api::types::error::Error),
63 #[error("Message ID `{0}` doesn't need to be promoted or reattached")]
65 NoNeedPromoteOrReattach(String),
66 #[error("Message ID `{0}` couldn't get included into the Tangle")]
68 TangleInclusionError(String),
69 #[cfg(feature = "mqtt")]
71 #[error("{0}")]
72 MqttClientError(#[from] rumqttc::ClientError),
73 #[error("The MQTT topic {0} is invalid")]
75 InvalidMqttTopic(String),
76 #[error("MQTT connection not found (all nodes have the MQTT plugin disabled)")]
78 MqttConnectionNotFound,
79 #[error("{0}")]
81 IoError(#[from] std::io::Error),
82 #[error("{0}")]
84 Json(#[from] serde_json::Error),
85 #[error("{0}")]
87 Pow(String),
88 #[error("Address: {0} not found in range: {1}")]
90 InputAddressNotFound(String, String),
91 #[cfg(feature = "storage")]
93 #[error("Storage adapter not set {0}")]
94 StorageAdapterNotSet(String),
95 #[cfg(feature = "storage")]
97 #[error("Storage error {0}")]
98 Storage(String),
99 #[cfg(feature = "storage")]
101 #[error("Account not found")]
102 AccountNotFound,
103 #[error("{0}")]
105 CryptoError(#[from] crypto::Error),
106 #[error("{0}")]
108 MnemonicError(String),
109 #[error("Invalid amount of parents: {0}, length must be in 1..=8")]
111 InvalidParentsAmount(usize),
112 #[cfg(feature = "sync")]
114 #[error("{0}")]
115 UreqError(Box<ureq::Error>),
116 #[cfg(any(feature = "async", feature = "wasm"))]
118 #[error("Response error with status code {0}: {1}")]
119 ResponseError(u16, String),
120 #[cfg(any(feature = "async", feature = "wasm"))]
122 #[error("{0}")]
123 ReqwestError(#[from] reqwest::Error),
124 #[error("{0}")]
126 UrlError(#[from] url::ParseError),
127 #[error("{0}")]
129 UrlValidationError(String),
130 #[error("Can't set {0} to URL")]
132 UrlAuthError(String),
133 #[error("{0}")]
135 Blake2b256Error(&'static str),
136 #[error("Output error: {0}")]
138 OutputError(&'static str),
139 #[cfg(not(feature = "wasm"))]
140 #[error("{0}")]
142 TaskJoinError(#[from] tokio::task::JoinError),
143 #[error("Invalid mnemonic {0}")]
145 InvalidMnemonic(String),
146 #[error("{0}")]
148 PowError(#[from] bee_pow::providers::miner::Error),
149 #[error("Invalid API name")]
151 ApiError,
152 #[error("Rw lock failed")]
154 PoisonError,
155}
156
157#[cfg(feature = "sync")]
158impl From<ureq::Error> for Error {
159 fn from(error: ureq::Error) -> Self {
160 Error::UreqError(Box::new(error))
161 }
162}