use super::routing_table::Error as RoutingTableError;
use action::Action;
use config_file_handler::Error as ConfigFileHandlerError;
use crust::CrustError;
use event::Event;
use id::PublicId;
use maidsafe_utilities::event_sender::{EventSenderError, MaidSafeEventCategory};
use maidsafe_utilities::serialisation;
use sha3::Digest256;
use std::sync::mpsc::{RecvError, SendError};
#[derive(Debug)]
#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
pub enum InterfaceError {
NotConnected,
InvalidState,
ChannelRxError(RecvError),
EventSenderError(EventSenderError<MaidSafeEventCategory, Action>),
}
impl From<EventSenderError<MaidSafeEventCategory, Action>> for InterfaceError {
fn from(error: EventSenderError<MaidSafeEventCategory, Action>) -> InterfaceError {
InterfaceError::EventSenderError(error)
}
}
impl From<RecvError> for InterfaceError {
fn from(error: RecvError) -> InterfaceError {
InterfaceError::ChannelRxError(error)
}
}
#[derive(Debug)]
#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
pub enum RoutingError {
NotBootstrapped,
Terminated,
BadAuthority,
AlreadyConnected,
AlreadyHandlingJoinRequest,
UnknownMessageType,
FailedSignature,
NotEnoughSignatures,
DuplicateSignatures,
InvalidOwners,
FilterCheckFailed,
FailedToBootstrap,
InvalidRelocationTargetRange,
RejectedClientMessage,
RoutingTable(RoutingTableError),
Utf8(::std::str::Utf8Error),
Interface(InterfaceError),
Io(::std::io::Error),
Crust(CrustError),
SendEventError(SendError<Event>),
InvalidStateForOperation,
SerialisationError(serialisation::SerialisationError),
AsymmetricDecryptionFailure,
UnknownConnection(PublicId),
InvalidDestination,
ProxyConnectionNotFound,
ClientConnectionNotFound,
InvalidSource,
CannotTunnelThroughTunnel,
HashMismatch,
InvalidSuccessor,
UnknownCandidate,
TimedOut,
FailedResourceProofValidation,
CandidateIsTunnelling,
InvalidMessage,
InvalidPeer,
ExceedsRateLimit(Digest256),
ConfigError(ConfigFileHandlerError),
}
impl From<RoutingTableError> for RoutingError {
fn from(error: RoutingTableError) -> RoutingError {
RoutingError::RoutingTable(error)
}
}
impl From<::std::str::Utf8Error> for RoutingError {
fn from(error: ::std::str::Utf8Error) -> RoutingError {
RoutingError::Utf8(error)
}
}
impl From<::std::io::Error> for RoutingError {
fn from(error: ::std::io::Error) -> RoutingError {
RoutingError::Io(error)
}
}
impl From<InterfaceError> for RoutingError {
fn from(error: InterfaceError) -> RoutingError {
RoutingError::Interface(error)
}
}
impl From<CrustError> for RoutingError {
fn from(error: CrustError) -> RoutingError {
RoutingError::Crust(error)
}
}
impl From<SendError<Event>> for RoutingError {
fn from(error: SendError<Event>) -> RoutingError {
RoutingError::SendEventError(error)
}
}
impl From<serialisation::SerialisationError> for RoutingError {
fn from(error: serialisation::SerialisationError) -> RoutingError {
RoutingError::SerialisationError(error)
}
}
impl From<ConfigFileHandlerError> for RoutingError {
fn from(error: ConfigFileHandlerError) -> RoutingError {
RoutingError::ConfigError(error)
}
}
quick_error! {
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum BootstrapResponseError {
NotApproved {
description("Proxy not approved yet")
display("The chosen proxy node has not yet been approved by the network.")
}
TooFewPeers {
description("Proxy has too few peers")
display("The chosen proxy node has too few connections to peers.")
}
ClientLimit {
description("Proxy has max. clients")
display("The chosen proxy node already has connections to the maximum number of \
clients allowed per proxy.")
}
}
}