diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/error.rs b/src/error.rs index 531528f..15e4308 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -1,21 +1,34 @@ | |||
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("ws")] | ||
33 | WsResponse, | ||
21 | } | 34 | } |