use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum ZerobusError {
#[error("Configuration error: {0}")]
ConfigurationError(String),
#[error("Authentication error: {0}")]
AuthenticationError(String),
#[error("Connection error: {0}")]
ConnectionError(String),
#[error("Conversion error: {0}")]
ConversionError(String),
#[error("Transmission error: {0}")]
TransmissionError(String),
#[error("Retry exhausted: {0}")]
RetryExhausted(String),
#[error("Token refresh error: {0}")]
TokenRefreshError(String),
}
impl ZerobusError {
pub fn is_retryable(&self) -> bool {
matches!(
self,
ZerobusError::ConnectionError(_) | ZerobusError::TransmissionError(_)
)
}
pub fn is_token_expired(&self) -> bool {
matches!(self, ZerobusError::AuthenticationError(_))
}
}