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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
use std::error;
use derive_more::Display;
use vapory_types::Address;
use tetsy_rlp::DecoderError;
use vaptrie::TrieError;
use types::{
errors::{VapcoreError, ExecutionError},
transaction::Error as TransactionError,
};
use crypto::publickey::Error as CryptoError;
use txpool::VerifiedTransaction;
use crate::private_transactions::VerifiedPrivateTransaction;
use serde_json::{Error as SerdeError};
type TxPoolError = txpool::Error<<VerifiedPrivateTransaction as VerifiedTransaction>::Hash>;
#[derive(Debug, Display)]
pub enum Error {
#[display(fmt = "Io Error: {}", _0)]
Io(::std::io::Error),
#[display(fmt = "Decoder Error: {}", _0)]
Decoder(DecoderError),
#[display(fmt = "Trie Error: {}", _0)]
Trie(TrieError),
#[display(fmt = "Transaction Pool Error: {}", _0)]
TxPool(TxPoolError),
#[display(fmt = "Crypto Error {}", _0)]
Crypto(CryptoError),
#[display(fmt = "Serialization Error {}", _0)]
Json(SerdeError),
#[display(fmt = "Encryption error. ({})", _0)]
Encrypt(String),
#[display(fmt = "Decryption error. ({})", _0)]
Decrypt(String),
#[display(fmt = "Private transaction execution is not authorised for {}", _0)]
NotAuthorised(Address),
#[display(fmt = "Private transaction created too many contracts")]
TooManyContracts,
#[display(fmt = "Contract call error. ({})", _0)]
Call(String),
#[display(fmt = "State is not available")]
StatePruned,
#[display(fmt = "State is incorrect")]
StateIncorrect,
#[display(fmt = "Wrong private transaction type")]
BadTransactionType,
#[display(fmt = "Contract does not exist or was not created")]
ContractDoesNotExist,
#[display(fmt = "Reference to the client is corrupted")]
ClientIsMalformed,
#[display(fmt = "Queue of private transactions for verification is full")]
QueueIsFull,
#[display(fmt = "The transaction already exists in queue of private transactions.")]
PrivateTransactionAlreadyImported,
#[display(fmt = "The information about private transaction is not found in the store.")]
PrivateTransactionNotFound,
#[display(fmt = "Account for signing public transactions not set.")]
SignerAccountNotSet,
#[display(fmt = "Account for validating private transactions not set.")]
ValidatorAccountNotSet,
#[display(fmt = "Account for signing requests to key server not set.")]
KeyServerAccountNotSet,
#[display(fmt = "Private state for the contract was not found in the local storage.")]
PrivateStateNotFound,
#[display(fmt = "Cannot write state to the local database.")]
DatabaseWriteError,
#[display(fmt = "Encryption key is not found on key server for {}", _0)]
EncryptionKeyNotFound(Address),
#[display(fmt = "Key server URL is not set.")]
KeyServerNotSet,
#[display(fmt = "Private transaction not found in logs.")]
TxNotFoundInLog,
#[display(fmt = "Path for logging not set.")]
LoggingPathNotSet,
#[display(fmt = "Timestamp overflow error.")]
TimestampOverflow,
#[display(fmt = "VM execution error {}", _0)]
Execution(ExecutionError),
#[display(fmt = "Error of transactions processing {}", _0)]
Transaction(TransactionError),
#[display(fmt = "General vapcore error {}", _0)]
Vapcore(VapcoreError),
#[display(fmt = "{}", _0)]
Msg(String),
}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::Io(e) => Some(e),
Error::Decoder(e) => Some(e),
Error::Trie(e) => Some(e),
Error::TxPool(e) => Some(e),
Error::Json(e) => Some(e),
Error::Crypto(e) => Some(e),
Error::Execution(e) => Some(e),
Error::Transaction(e) => Some(e),
Error::Vapcore(e) => Some(e),
_ => None,
}
}
}
impl From<String> for Error {
fn from(s: String) -> Self {
Error::Msg(s)
}
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Io(err).into()
}
}
impl From<CryptoError> for Error {
fn from(err: CryptoError) -> Self {
Error::Crypto(err).into()
}
}
impl From<DecoderError> for Error {
fn from(err: DecoderError) -> Self {
Error::Decoder(err).into()
}
}
impl From<ExecutionError> for Error {
fn from(err: ExecutionError) -> Self {
Error::Execution(err).into()
}
}
impl From<TransactionError> for Error {
fn from(err: TransactionError) -> Self {
Error::Transaction(err).into()
}
}
impl From<TrieError> for Error {
fn from(err: TrieError) -> Self {
Error::Trie(err).into()
}
}
impl From<TxPoolError> for Error {
fn from(err: TxPoolError) -> Self {
Error::TxPool(err).into()
}
}
impl From<SerdeError> for Error {
fn from(err: SerdeError) -> Self {
Error::Json(err).into()
}
}
impl From<VapcoreError> for Error {
fn from(err: VapcoreError) -> Self {
Error::Vapcore(err).into()
}
}
impl<E> From<Box<E>> for Error where Error: From<E> {
fn from(err: Box<E>) -> Error {
Error::from(*err)
}
}