workflow_utils/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5    #[error("{0}")]
6    Custom(String),
7
8    #[error(transparent)]
9    Io(#[from] std::io::Error),
10
11    #[error(transparent)]
12    Reqwest(#[from] reqwest::Error),
13
14    #[error(transparent)]
15    InvalidHeaderName(#[from] reqwest::header::InvalidHeaderName),
16
17    #[error(transparent)]
18    InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
19
20    #[error(transparent)]
21    ParseInt(#[from] std::num::ParseIntError),
22
23    #[error(transparent)]
24    Http(#[from] workflow_http::error::Error),
25}
26
27impl From<String> for Error {
28    fn from(s: String) -> Self {
29        Error::Custom(s)
30    }
31}
32
33impl From<&str> for Error {
34    fn from(s: &str) -> Self {
35        Error::Custom(s.to_string())
36    }
37}
38
39impl Error {
40    pub fn custom<T: std::fmt::Display>(msg: T) -> Self {
41        Error::Custom(msg.to_string())
42    }
43}
44
45// impl From<reqwest::Error> for Error {
46//     fn from(err: reqwest::Error) -> Self {
47//         Self::Reqwest(err)
48//     }
49// }