del_rs/
errors.rs

1use reqwest::header::InvalidHeaderValue;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug)]
5pub struct DelError {
6    pub error: bool,
7    pub status: Option<u16>,
8    pub message: String,
9}
10
11impl From<reqwest::Error> for DelError {
12    fn from(err: reqwest::Error) -> Self {
13        Self {
14            error: true,
15            status: err.status().map(|s| s.as_u16()),
16            message: err.to_string(),
17        }
18    }
19}
20
21impl From<InvalidHeaderValue> for DelError {
22    fn from(err: InvalidHeaderValue) -> Self {
23        Self {
24            error: true,
25            status: None,
26            message: err.to_string(),
27        }
28    }
29}