diff options
author | FxQnLr <[email protected]> | 2024-02-25 16:54:03 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-02-25 16:54:03 +0100 |
commit | 465a71b6780921fb7ec19682702cbe864decd212 (patch) | |
tree | 66d9a386045a98e95a50d7f84e7e3044b578a163 /src/error.rs | |
parent | 03bea24f9de698375033af92a08762446d0e20cc (diff) | |
download | webol-cli-465a71b6780921fb7ec19682702cbe864decd212.tar webol-cli-465a71b6780921fb7ec19682702cbe864decd212.tar.gz webol-cli-465a71b6780921fb7ec19682702cbe864decd212.zip |
Closes #3. Use thiserror. Fix clippy stuff
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 | } |