axonflow_sdk_rust/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AxonFlowError {
5 #[error("HTTP request failed: {0}")]
6 HttpError(#[from] reqwest::Error),
7 #[error("Serialization/Deserialization failed: {0}")]
8 SerdeError(#[from] serde_json::Error),
9 #[error("API error ({status}): {message}")]
10 ApiError { status: u16, message: String },
11 #[error("Configuration error: {0}")]
12 ConfigError(String),
13 #[error("AxonFlow platform is unavailable: {0}")]
14 Unavailable(String),
15}
16
17impl AxonFlowError {
18 pub fn is_retryable(&self) -> bool {
19 match self {
20 AxonFlowError::HttpError(e) => e.is_timeout() || e.is_connect(),
21 AxonFlowError::ApiError { status, .. } => *status >= 500 || *status == 429,
22 AxonFlowError::Unavailable(_) => true,
23 _ => false,
24 }
25 }
26
27 pub fn is_fail_open_eligible(&self) -> bool {
28 match self {
29 AxonFlowError::HttpError(e) => e.is_timeout() || e.is_connect(),
30 AxonFlowError::ApiError { status, .. } => *status >= 500 || *status == 429,
31 AxonFlowError::Unavailable(_) => true,
32 _ => false,
33 }
34 }
35}