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
use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
MissingSeed,
NodePoolEmpty,
NotTailHash,
QuorumError,
QuorumThreshold,
ReqwestError(reqwest::Error),
ResponseError(String),
TernaryError,
ThresholdNotEnough,
UrlError,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::MissingSeed => "Must provide seed to prepare transfer".fmt(f),
Error::NodePoolEmpty => "No node available".fmt(f),
Error::NotTailHash => "Provided hash is not tail".fmt(f),
Error::QuorumError => "Fail to find quorum result".fmt(f),
Error::QuorumThreshold => "Quorum result didn't pass the minimum threshold".fmt(f),
Error::ReqwestError(e) => e.fmt(f),
Error::ResponseError(s) => s.fmt(f),
Error::ThresholdNotEnough => "Cannot find enough inputs to satisify threshold".fmt(f),
Error::TernaryError => "Fail to convert message to trytes".fmt(f),
Error::UrlError => "Fail to parse url".fmt(f),
}
}
}
impl std::error::Error for Error {}
impl From<reqwest::Error> for Error {
fn from(error: reqwest::Error) -> Self {
Error::ReqwestError(error)
}
}