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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
use serde::{Deserialize, Serialize};
use std::{
fmt::{self, Debug, Formatter},
result,
};
use sn_data_types::PublicKey;
use thiserror::Error;
pub type Result<T> = result::Result<T, Error>;
pub struct ErrorDebug<'a, T>(pub &'a Result<T>);
impl<'a, T> Debug for ErrorDebug<'a, T> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if let Err(error) = self.0 {
write!(f, "{:?}", error)
} else {
write!(f, "Success")
}
}
}
#[derive(Error, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[non_exhaustive]
#[allow(clippy::large_enum_variant)]
pub enum Error {
#[error("Unsupported messaging protocol version: {0}")]
UnsupportedVersion(u16),
#[error("Unsupported payload serialization: {0}")]
UnsupportedSerialization(u16),
#[error("Access denied for PublicKey: {0}")]
AccessDenied(PublicKey),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Requested data not found")]
NoSuchData,
#[error("No history found for PublicKey: {0}")]
NoHistoryForPublicKey(sn_data_types::PublicKey),
#[error("Failed to write file")]
FailedToWriteFile,
#[error("Data provided already exists")]
DataExists,
#[error("Requested entry not found")]
NoSuchEntry,
#[error("Exceeded a limit on a number of entries")]
TooManyEntries,
#[error("Key does not exist")]
NoSuchKey,
#[error("Node does not have sufficient space to store chunk")]
NotEnoughSpace,
#[error("Duplicate entries provided")]
DuplicateEntryKeys,
#[error("Invalid owner key: {0}")]
InvalidOwners(sn_data_types::PublicKey),
#[error("No policy has been set for this data")]
PolicyNotSet,
#[error("Invalid version provided: {0}")]
InvalidSuccessor(u64),
#[error("Invalid owners version provided: {0}")]
InvalidOwnersSuccessor(u64),
#[error("Operation is not causally ready. Ensure you have the full history of operations.")]
OpNotCausallyReady,
#[error("Invalid permission version provided: {0}")]
InvalidPermissionsSuccessor(u64),
#[error("Invalid operation")]
InvalidOperation,
#[error("Sign key and signature type do not match")]
SigningKeyTypeMismatch,
#[error("Invalid signature")]
InvalidSignature,
#[error("Duplicate message id received")]
DuplicateMessageId,
#[error("Lost precision on the number of coins during parsing")]
LossOfPrecision,
#[error("The money amount would exceed the maximum value (u64::MAX)")]
ExcessiveValue,
#[error("Failed to parse: {0}")]
FailedToParse(String),
#[error("Transaction Id already exists")]
TransactionIdExists,
#[error("Insufficient balance to complete this operation")]
InsufficientBalance,
#[error("No such key exists")]
NoSuchBalance,
#[error("No such sender key balance")]
NoSuchSender,
#[error("No such recipient key balance")]
NoSuchRecipient,
#[error("Key already exists")]
BalanceExists,
#[error("Size of the structure exceeds the limit")]
ExceededSize,
#[error("CRDT operation missing actor signature")]
CrdtMissingOpSignature,
#[error("CRDT data is in an unexpected and/or inconsistent state. No data found for current policy.")]
CrdtUnexpectedState,
#[error("Entry already exists {0}")]
EntryExists(u8),
#[error("Payment registration failed")]
PaymentFailed,
#[error("Failed to delete requested data")]
FailedToDelete,
#[error("Node is not being relocated")]
NodeWasNotRelocated,
}