1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
use qp2p::Error as QuicP2pError;
use sn_data_types::{Error as DtError, PublicKey};
pub use sn_messaging::client::Error as ErrorMessage;
use sn_messaging::client::{CmdError, Event, QueryResponse, TransferError};
pub use sn_messaging::Error as MessagingError;
pub use sn_transfers::Error as TransfersError;
use std::io;
use thiserror::Error;
#[allow(clippy::large_enum_variant)]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Asymmetric key decryption failure")]
AsymmetricDecipherFailure,
#[error("Symmetric key decryption failure")]
SymmetricDecipherFailure,
#[error("Unexpected data received")]
ReceivedUnexpectedData,
#[error("Unexpected event received")]
ReceivedUnexpectedEvent,
#[error("Problem querying elder")]
ElderQuery,
#[error("Problem connecting to elder")]
ElderConnection,
#[error("Client has failed to bootstrap yet")]
NotBootstrapped,
#[error("Problem connecting to sufficient elder")]
InsufficientElderConnections,
#[error("Problem receiving query via qp2p")]
ReceivingQuery,
#[error("Problem sending query via qp2p")]
SendingQuery,
#[error("Problem receiving query internally in sn_client")]
QueryReceiverError,
#[error("Failed to obtain a response")]
NoResponse,
#[error("Failed to obtain a response")]
NoTransferValidationListener,
#[error("Unexpected message type receivied while joining: {0}")]
UnexpectedMessageOnJoin(String),
#[error("Expected public permission set")]
NotPublicPermissions,
#[error("Expected private permission set")]
NotPrivatePermissions,
#[error("Could not listen on elder connection")]
NoElderListenerEstablished,
#[error(" Incorrect user permissions were returned")]
IncorrectPermissions,
#[error("Unexpcted transfer event received {0:?}")]
UnexpectedTransferEvent(Event),
#[error("Unexpected response received when querying {0:?}")]
UnexpectedQueryResponse(QueryResponse),
#[error("Unexpected response received when querying balance history {0:?}")]
UnexpectedHistoryResponse(QueryResponse),
#[error("Unexpected response received when querying store cost: {0:?}")]
UnexpectedStoreCostResponse(QueryResponse),
#[error("Unexpected response received when querying replica keys for PublicKey: {0:?}")]
UnexpectedReplicaKeysResponse(PublicKey),
#[error("No transfer generated by transfer actor")]
NoTransferGenerated,
#[error("Transfer actor did not find any events to register locally")]
NoTransferEventsForLocalActor,
#[error("Simulated payouts unavailable without 'simualted-payouts' feature flag at build")]
NotBuiltWithSimulatedPayouts,
#[error(transparent)]
NetworkDataError(#[from] DtError),
#[error(transparent)]
Transfer(#[from] TransfersError),
#[error(transparent)]
ErrorMessage(#[from] ErrorMessage),
#[error(transparent)]
MessagingProtocol(#[from] MessagingError),
#[error(transparent)]
SelfEncryption(#[from] self_encryption::SelfEncryptionError),
#[error(transparent)]
ConfigError(#[from] serde_json::Error),
#[error(transparent)]
IoError(#[from] io::Error),
#[error(transparent)]
QuicP2p(#[from] QuicP2pError),
#[error(transparent)]
Serialisation(#[from] Box<bincode::ErrorKind>),
}
impl From<CmdError> for Error {
fn from(error: CmdError) -> Self {
let err = match error {
CmdError::Data(data_err) => data_err,
CmdError::Transfer(err) => match err {
TransferError::TransferValidation(err) => err,
TransferError::TransferRegistration(err) => err,
},
CmdError::Auth(auth_error) => auth_error,
};
Error::ErrorMessage(err)
}
}