1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum DrmError {
5 #[error("network error: {0}")]
6 Network(#[from] NetworkError),
7
8 #[error("exchange error: {0}")]
9 Exchange(#[from] ExchangeError),
10
11 #[error("websocket error: {0}")]
12 WebSocket(#[from] WebSocketError),
13
14 #[error("signing error: {0}")]
15 Signing(#[from] SigningError),
16
17 #[error("rate limit exceeded")]
18 RateLimitExceeded,
19
20 #[error("serialization error: {0}")]
21 Serialization(#[from] serde_json::Error),
22
23 #[error("configuration error: {0}")]
24 Config(String),
25
26 #[error("invalid input: {0}")]
27 InvalidInput(String),
28
29 #[error("{0}")]
30 Other(String),
31}
32
33#[derive(Debug, Error)]
34pub enum NetworkError {
35 #[error("http request failed: {0}")]
36 Http(String),
37
38 #[error("timeout after {0}ms")]
39 Timeout(u64),
40
41 #[error("connection failed: {0}")]
42 Connection(String),
43}
44
45#[derive(Debug, Error)]
46pub enum ExchangeError {
47 #[error("market not found: {0}")]
48 MarketNotFound(String),
49
50 #[error("invalid order: {0}")]
51 InvalidOrder(String),
52
53 #[error("order rejected: {0}")]
54 OrderRejected(String),
55
56 #[error("insufficient funds: {0}")]
57 InsufficientFunds(String),
58
59 #[error("authentication failed: {0}")]
60 Authentication(String),
61
62 #[error("not supported: {0}")]
63 NotSupported(String),
64
65 #[error("api error: {0}")]
66 Api(String),
67}
68
69#[derive(Debug, Clone, Error)]
70pub enum WebSocketError {
71 #[error("connection error: {0}")]
72 Connection(String),
73
74 #[error("connection closed")]
75 Closed,
76
77 #[error("protocol error: {0}")]
78 Protocol(String),
79
80 #[error("subscription failed: {0}")]
81 Subscription(String),
82}
83
84#[derive(Debug, Error)]
85pub enum SigningError {
86 #[error("invalid private key")]
87 InvalidKey,
88
89 #[error("signing failed: {0}")]
90 SigningFailed(String),
91
92 #[error("unsupported operation: {0}")]
93 Unsupported(String),
94}