use std::time::Duration;
#[derive(Debug, thiserror::Error)]
#[error("circuit open for provider {provider}: retry after {retry_after:?}")]
pub struct CircuitOpenError {
pub provider: String,
pub retry_after: Duration,
}
#[derive(Debug, thiserror::Error)]
#[error("all {attempts} hedged attempts exhausted")]
pub struct HedgeExhaustedError {
pub attempts: u32,
}
impl From<CircuitOpenError> for crate::error::LiterLlmError {
fn from(e: CircuitOpenError) -> Self {
Self::ServiceUnavailable {
message: e.to_string(),
status: 503,
}
}
}
impl From<HedgeExhaustedError> for crate::error::LiterLlmError {
fn from(_e: HedgeExhaustedError) -> Self {
Self::Timeout
}
}