diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/src/error.rs b/src/error.rs index f15c60a..1e6eac1 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -1,21 +1,43 @@ | |||
1 | use std::{fmt::Debug, num::ParseIntError}; | 1 | use std::{fmt::Debug, num::ParseIntError}; |
2 | 2 | ||
3 | pub enum CliError { | 3 | use reqwest::header::InvalidHeaderValue; |
4 | Reqwest(reqwest::Error), | ||
5 | Config(config::ConfigError), | ||
6 | Serde(serde_json::Error), | ||
7 | Parse(ParseIntError), | ||
8 | WsResponse, | ||
9 | } | ||
10 | 4 | ||
11 | impl Debug for CliError { | 5 | #[derive(Debug, thiserror::Error)] |
12 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 6 | pub enum Error { |
13 | match self { | 7 | #[error("request: {source}")] |
14 | Self::Reqwest(err) => { err.fmt(f) }, | 8 | Reqwest { |
15 | Self::Config(err) => { err.fmt(f) }, | 9 | #[from] |
16 | Self::Serde(err) => { err.fmt(f) }, | 10 | source: reqwest::Error, |
17 | Self::Parse(err) => { err.fmt(f) }, | 11 | }, |
18 | Self::WsResponse => { f.write_str("Error in Response") }, | 12 | #[error("config: {source}")] |
19 | } | 13 | Config { |
20 | } | 14 | #[from] |
15 | source: config::ConfigError, | ||
16 | }, | ||
17 | #[error("serde: {source}")] | ||
18 | Serde { | ||
19 | #[from] | ||
20 | source: serde_json::Error, | ||
21 | }, | ||
22 | #[error("parse int: {source}")] | ||
23 | Parse { | ||
24 | #[from] | ||
25 | source: ParseIntError, | ||
26 | }, | ||
27 | #[error("parse header: {source}")] | ||
28 | InvalidHeaderValue { | ||
29 | #[from] | ||
30 | source: InvalidHeaderValue, | ||
31 | }, | ||
32 | #[error("tungstenite: {source}")] | ||
33 | Tungstenite { | ||
34 | #[from] | ||
35 | source: tokio_tungstenite::tungstenite::Error, | ||
36 | }, | ||
37 | #[error("faulty websocket response")] | ||
38 | WsResponse, | ||
39 | #[error("authorization failed")] | ||
40 | Authorization, | ||
41 | #[error("Http error status: {0}")] | ||
42 | HttpStatus(u16), | ||
21 | } | 43 | } |