pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[allow(clippy::large_enum_variant)]
pub enum Error {
#[error("Error when building indexation message: {0}")]
IndexationError(String),
#[error("Error when building transaction message")]
TransactionError,
#[error("The wallet account doesn't have enough balance. It only has {0}, required is {1}")]
NotEnoughBalance(u64, u64),
#[error(
"The wallet account has enough funds, but splitted on too many outputs: {0}, max. is 127, consolidate them"
)]
ConsolidationRequired(usize),
#[error("Dust error: {0}")]
DustError(String),
#[error("Must provide required parameter: {0}")]
MissingParameter(&'static str),
#[error("Parameter is invalid:{0}")]
InvalidParameter(&'static str),
#[error("No synced node available")]
SyncedNodePoolEmpty,
#[error("Failed to parse node_pool_urls")]
NodePoolUrlsError,
#[error("Failed to reach quorum {0} {1}")]
QuorumThresholdError(usize, usize),
#[error("Not enough nodes for quorum {0} {1}")]
QuorumPoolSizeError(usize, usize),
#[error("Node error: {0}")]
NodeError(String),
#[error("Failed to read node RwLock")]
NodeReadError,
#[error("{0}")]
FromHexError(#[from] hex::FromHexError),
#[error("{0}")]
MessageError(#[from] bee_message::Error),
#[error("{0}")]
BeeRestApiError(#[from] bee_rest_api::types::error::Error),
#[error("Message ID `{0}` doesn't need to be promoted or reattached")]
NoNeedPromoteOrReattach(String),
#[error("Message ID `{0}` couldn't get included into the Tangle")]
TangleInclusionError(String),
#[cfg(feature = "mqtt")]
#[error("{0}")]
MqttClientError(#[from] rumqttc::ClientError),
#[error("The MQTT topic {0} is invalid")]
InvalidMqttTopic(String),
#[error("MQTT connection not found (all nodes have the MQTT plugin disabled)")]
MqttConnectionNotFound,
#[error("{0}")]
IoError(#[from] std::io::Error),
#[error("{0}")]
Json(#[from] serde_json::Error),
#[error("{0}")]
Pow(String),
#[error("Address: {0} not found in range: {1}")]
InputAddressNotFound(String, String),
#[cfg(feature = "storage")]
#[error("Storage adapter not set {0}")]
StorageAdapterNotSet(String),
#[cfg(feature = "storage")]
#[error("Storage error {0}")]
Storage(String),
#[cfg(feature = "storage")]
#[error("Account not found")]
AccountNotFound,
#[error("{0}")]
CryptoError(#[from] crypto::Error),
#[error("{0}")]
MnemonicError(String),
#[error("Invalid amount of parents: {0}, length must be in 1..=8")]
InvalidParentsAmount(usize),
#[cfg(feature = "sync")]
#[error("{0}")]
UreqError(Box<ureq::Error>),
#[cfg(any(feature = "async", feature = "wasm"))]
#[error("Response error with status code {0}: {1}")]
ResponseError(u16, String),
#[cfg(any(feature = "async", feature = "wasm"))]
#[error("{0}")]
ReqwestError(#[from] reqwest::Error),
#[error("{0}")]
UrlError(#[from] url::ParseError),
#[error("{0}")]
UrlValidationError(String),
#[error("Can't set {0} to URL")]
UrlAuthError(String),
#[error("{0}")]
Blake2b256Error(&'static str),
#[error("Output error: {0}")]
OutputError(&'static str),
#[cfg(not(feature = "wasm"))]
#[error("{0}")]
TaskJoinError(#[from] tokio::task::JoinError),
#[error("Invalid mnemonic {0}")]
InvalidMnemonic(String),
#[error("{0}")]
PowError(#[from] bee_pow::providers::miner::Error),
#[error("Invalid API name")]
ApiError,
#[error("Rw lock failed")]
PoisonError,
}
#[cfg(feature = "sync")]
impl From<ureq::Error> for Error {
fn from(error: ureq::Error) -> Self {
Error::UreqError(Box::new(error))
}
}