buswatch_adapters/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum AdapterError {
8 #[error("HTTP request failed: {0}")]
10 Http(String),
11
12 #[error("Failed to parse response: {0}")]
14 Parse(String),
15
16 #[error("Authentication failed: {0}")]
18 Auth(String),
19
20 #[error("Connection failed: {0}")]
22 Connection(String),
23
24 #[error("Request timed out")]
26 Timeout,
27
28 #[error("Feature not supported: {0}")]
30 Unsupported(String),
31}
32
33#[cfg(feature = "rabbitmq")]
34impl From<reqwest::Error> for AdapterError {
35 fn from(err: reqwest::Error) -> Self {
36 if err.is_timeout() {
37 AdapterError::Timeout
38 } else if err.is_connect() {
39 AdapterError::Connection(err.to_string())
40 } else {
41 AdapterError::Http(err.to_string())
42 }
43 }
44}