reqwest_builder/
errors.rs1#[derive(Debug, Clone, PartialEq)]
3pub enum ReqwestBuilderError {
4 SerializationError(String),
6 HeaderError {
8 key: String,
9 value: String,
10 source: String,
11 },
12 UrlError(String),
14 IoError(String),
16 InvalidRequest(String),
18}
19
20impl std::fmt::Display for ReqwestBuilderError {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 match self {
23 ReqwestBuilderError::SerializationError(msg) => {
24 write!(f, "Serialization error: {}", msg)
25 }
26 ReqwestBuilderError::HeaderError { key, value, source } => {
27 write!(f, "Header error for '{}': '{}' - {}", key, value, source)
28 }
29 ReqwestBuilderError::UrlError(msg) => write!(f, "URL error: {}", msg),
30 ReqwestBuilderError::IoError(msg) => write!(f, "I/O error: {}", msg),
31 ReqwestBuilderError::InvalidRequest(msg) => write!(f, "Invalid request: {}", msg),
32 }
33 }
34}
35
36impl std::error::Error for ReqwestBuilderError {}
37
38impl From<std::io::Error> for ReqwestBuilderError {
39 fn from(err: std::io::Error) -> Self {
40 ReqwestBuilderError::IoError(err.to_string())
41 }
42}
43
44impl From<serde_json::Error> for ReqwestBuilderError {
45 fn from(err: serde_json::Error) -> Self {
46 ReqwestBuilderError::SerializationError(err.to_string())
47 }
48}