**Goal**: Prevent response.failed events with `invalid_prompt` from being treated as retryable errors so the UI shows the actual error message instead of continually retrying. **Before**: Codex would continue to retry despite the prompt being marked as disallowed **After**: Codex will stop retrying once prompt is marked disallowed
36 lines
974 B
Rust
36 lines
974 B
Rust
use crate::rate_limits::RateLimitError;
|
|
use codex_client::TransportError;
|
|
use http::StatusCode;
|
|
use std::time::Duration;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum ApiError {
|
|
#[error(transparent)]
|
|
Transport(#[from] TransportError),
|
|
#[error("api error {status}: {message}")]
|
|
Api { status: StatusCode, message: String },
|
|
#[error("stream error: {0}")]
|
|
Stream(String),
|
|
#[error("context window exceeded")]
|
|
ContextWindowExceeded,
|
|
#[error("quota exceeded")]
|
|
QuotaExceeded,
|
|
#[error("usage not included")]
|
|
UsageNotIncluded,
|
|
#[error("retryable error: {message}")]
|
|
Retryable {
|
|
message: String,
|
|
delay: Option<Duration>,
|
|
},
|
|
#[error("rate limit: {0}")]
|
|
RateLimit(String),
|
|
#[error("invalid request: {message}")]
|
|
InvalidRequest { message: String },
|
|
}
|
|
|
|
impl From<RateLimitError> for ApiError {
|
|
fn from(err: RateLimitError) -> Self {
|
|
Self::RateLimit(err.to_string())
|
|
}
|
|
}
|