summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-02-25 16:54:03 +0100
committerFxQnLr <[email protected]>2024-02-25 16:54:03 +0100
commit465a71b6780921fb7ec19682702cbe864decd212 (patch)
tree66d9a386045a98e95a50d7f84e7e3044b578a163 /src/error.rs
parent03bea24f9de698375033af92a08762446d0e20cc (diff)
downloadwebol-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.rs47
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 @@
1use std::{fmt::Debug, num::ParseIntError}; 1use std::{fmt::Debug, num::ParseIntError};
2 2
3pub enum CliError { 3use reqwest::header::InvalidHeaderValue;
4 Reqwest(reqwest::Error),
5 Config(config::ConfigError),
6 Serde(serde_json::Error),
7 Parse(ParseIntError),
8 WsResponse,
9}
10 4
11impl Debug for CliError { 5#[derive(Debug, thiserror::Error)]
12 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 6pub 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}