-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy patherror.rs
More file actions
75 lines (57 loc) · 2.33 KB
/
error.rs
File metadata and controls
75 lines (57 loc) · 2.33 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
use flex_error::{define_error, TraceError};
use tendermint_rpc::{Error as RpcError, WebSocketClientUrl};
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
define_error! {
#[derive(Debug, Clone)]
Error {
WebSocketDriver
[ TraceError<RpcError> ]
|_| { "WebSocket driver failed" },
ClientCreationFailed
{ chain_id: ChainId, address: WebSocketClientUrl }
|e| { format!("failed to create WebSocket driver for chain {0} with address {1}", e.chain_id, e.address) },
ClientTerminationFailed
[ TraceError<tokio::task::JoinError> ]
|_| { "failed to terminate previous WebSocket driver" },
ClientCompletionFailed
[ TraceError<RpcError> ]
|_| { "failed to run previous WebSocket driver to completion" },
ClientSubscriptionFailed
[ TraceError<RpcError> ]
|_| { "failed to run previous WebSocket driver to completion" },
NextEventBatchFailed
[ TraceError<RpcError> ]
|_| { "failed to collect events over WebSocket subscription" },
CollectEventsFailed
{ reason: String }
|e| { format!("failed to extract IBC events: {0}", e.reason) },
ChannelSendFailed
|_| { "event source: internal message-passing failure: could not send message" },
ChannelRecvFailed
|_| { "event source: internal message-passing failure: could not receive message" },
SubscriptionCancelled
[ TraceError<RpcError> ]
|_| { "subscription cancelled" },
Rpc
[ TraceError<RpcError> ]
|_| { "RPC error" },
StreamTerminated
|_| { "event stream terminated unexpectedly" },
WatchdogTimeout
{ timeout_secs: u64 }
|e| { format!("no events received for {} seconds", e.timeout_secs) },
DriverChannelClosed
|_| { "websocket driver channel closed" },
}
}
impl Error {
pub fn canceled_or_generic(e: RpcError) -> Self {
use tendermint_rpc::error::ErrorDetail;
match e.detail() {
ErrorDetail::Server(detail) if detail.reason.contains("subscription was cancelled") => {
Self::subscription_cancelled(e)
}
_ => Self::rpc(e),
}
}
}