use thiserror::Error;
pub type Result<T> = std::result::Result<T, RuntimeError>;
#[derive(Debug, Error)]
pub enum RuntimeError {
#[error("Configuration error: {0}")]
Config(String),
#[error("Provider not found: {0}")]
ProviderNotFound(String),
#[error("Capability mismatch: {0}")]
CapabilityMismatch(String),
#[error("Load error: {0}")]
Load(String),
#[error("API error: {0}")]
ApiError(String),
#[error("Inference error: {0}")]
InferenceError(String),
#[error("Rate limited")]
RateLimited,
#[error("Unauthorized")]
Unauthorized,
#[error("Timeout")]
Timeout,
#[error("Unavailable")]
Unavailable,
}
impl RuntimeError {
pub fn is_retryable(&self) -> bool {
matches!(self, Self::RateLimited | Self::Timeout | Self::Unavailable)
}
}