pub(crate) type Result<T> = std::result::Result<T, Error>;
use super::ClientEvent;
use sn_registers::{Entry, EntryHash};
use sn_transfers::SpendAddress;
use std::{collections::BTreeSet, time::Duration};
use thiserror::Error;
#[derive(Debug, Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("Genesis error {0}")]
GenesisError(#[from] sn_transfers::GenesisError),
#[error("Transfer Error {0}.")]
Transfers(#[from] sn_transfers::WalletError),
#[error("Network Error {0}.")]
Network(#[from] sn_networking::Error),
#[error("Protocol error {0}.")]
Protocol(#[from] sn_protocol::error::Error),
#[error("Register error {0}.")]
Register(#[from] sn_registers::Error),
#[error("Chunks error {0}.")]
Chunks(#[from] super::chunks::Error),
#[error("SelfEncryption Error {0}.")]
SelfEncryptionIO(#[from] self_encryption::Error),
#[error("System IO Error {0}.")]
SystemIO(#[from] std::io::Error),
#[error("Events receiver error {0}.")]
EventsReceiver(#[from] tokio::sync::broadcast::error::RecvError),
#[error("Events sender error {0}.")]
EventsSender(#[from] tokio::sync::broadcast::error::SendError<ClientEvent>),
#[error(transparent)]
JoinError(#[from] tokio::task::JoinError),
#[error("Failed to verify transfer validity in the network {0}")]
CouldNotVerifyTransfer(String),
#[error("Double spend detected at address: {0:?}")]
DoubleSpend(SpendAddress),
#[error("Serialization error: {0:?}")]
Serialization(#[from] rmp_serde::encode::Error),
#[error("Deserialization error: {0:?}")]
Deserialization(#[from] rmp_serde::decode::Error),
#[error("There is no Spend record at this address: {0:?}")]
MissingSpendRecord(SpendAddress),
#[error(
"Content branches detected in the Register which need to be merged/resolved by user. \
Entries hashes of branches are: {0:?}"
)]
ContentBranchDetected(BTreeSet<(EntryHash, Entry)>),
#[error("The provided amount contains zero nanos")]
AmountIsZero,
#[error("Total price exceed possible token amount")]
TotalPriceTooHigh,
#[error("Logic error: NonZeroUsize was initialised as zero")]
NonZeroUsizeWasInitialisedAsZero,
#[error("Could not connect to the network in {0:?}")]
ConnectionTimeout(Duration),
#[error("Too many sequential upload payment failures")]
SequentialUploadPaymentError,
#[error("Could not send files event")]
CouldNotSendFilesEvent,
#[error("Incorrect Download Option")]
IncorrectDownloadOption,
#[error("The provided data map is empty")]
EmptyDataMap,
#[error("Error occurred while assembling the downloaded chunks")]
FailedToAssembleDownloadedChunks,
#[error("Error occurred when access wallet file")]
FailedToAccessWallet,
#[error("Task completion notification channel is done")]
FailedToReadFromNotificationChannel,
}