use codex_protocol::protocol::RateLimitSnapshot; use reqwest::StatusCode; use thiserror::Error; pub type Result = std::result::Result; #[derive(Error, Debug)] pub enum Error { #[error("{0}")] UnsupportedOperation(String), #[error(transparent)] Http(#[from] reqwest::Error), #[error("response stream failed: {source}")] ResponseStreamFailed { #[source] source: reqwest::Error, request_id: Option, }, #[error("stream error: {0}")] Stream(String, Option), #[error("usage limit reached")] UsageLimitReached { plan_type: Option, resets_at: Option, rate_limits: Option, }, #[error("unexpected status {status}: {body}")] UnexpectedStatus { status: StatusCode, body: String }, #[error("retry limit reached {status:?} request_id={request_id:?}")] RetryLimit { status: Option, request_id: Option, }, #[error("missing env var {var}: {instructions:?}")] MissingEnvVar { var: String, instructions: Option, }, #[error("auth error: {0}")] Auth(String), #[error(transparent)] Json(#[from] serde_json::Error), #[error("{0}")] Other(String), }