-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy patherror.rs
More file actions
85 lines (75 loc) · 2.64 KB
/
Copy patherror.rs
File metadata and controls
85 lines (75 loc) · 2.64 KB
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
use std::fmt::Debug;
use crate::impl_sourceless_error;
/// Errors that prevent the node from running.
#[derive(Debug)]
pub enum NodeError {
/// The node has exhausted all possible options for peers.
NoReachablePeers,
}
impl core::fmt::Display for NodeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
NodeError::NoReachablePeers => {
write!(f, "the node has exhausted all possible options for peers")
}
}
}
}
impl_sourceless_error!(NodeError);
/// Errors occurring when the client is talking to the node.
#[derive(Debug)]
pub enum ClientError {
/// The channel to the node was likely closed and dropped from memory.
SendError,
/// A channel was dropped before sending its value back.
RecvError,
/// No peer requested the transaction within the configured broadcast timeout.
BroadcastTimeout,
}
impl core::fmt::Display for ClientError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ClientError::SendError => {
write!(f, "the receiver of this message was dropped from memory.")
}
ClientError::RecvError => {
write!(f, "the sender of data was dropped from memory.")
}
ClientError::BroadcastTimeout => {
write!(
f,
"no peer requested the transaction within the configured timeout."
)
}
}
}
}
impl_sourceless_error!(ClientError);
/// Errors occurring when the client is fetching blocks from the node.
#[derive(Debug)]
pub enum FetchBlockError {
/// The channel to the node was likely closed and dropped from memory.
/// This implies the node is not running.
SendError,
/// The channel to the client was likely closed by the node and dropped from memory.
RecvError,
/// The hash is not a member of the chain of most work.
UnknownHash,
}
impl core::fmt::Display for FetchBlockError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FetchBlockError::SendError => {
write!(f, "the receiver of this message was dropped from memory.")
}
FetchBlockError::RecvError => write!(
f,
"the channel to the client was likely closed by the node and dropped from memory."
),
FetchBlockError::UnknownHash => {
write!(f, "the hash is not a member of the chain of most work.")
}
}
}
}
impl_sourceless_error!(FetchBlockError);