pub enum ProxyError {
Upstream {
source: String,
inner: Option<Error>,
},
ProtocolConversion(String),
ChannelSelection {
model: String,
},
Compression(String),
BadRequest(String),
Unauthorized,
RateLimited {
retry_after: Duration,
},
CircuitOpen {
channel: String,
},
Internal(Error),
}Expand description
Top-level error for the proxy.
Maps to HTTP responses with appropriate status codes and JSON bodies.
Internal details are never leaked to clients — use tracing for server-side logging.
Variants§
Upstream
Upstream returned an error or was unreachable.
Fields
ProtocolConversion(String)
Protocol conversion between AI API formats failed.
ChannelSelection
No channel could be selected for the requested model.
Compression(String)
Token compression failed (non-fatal — falls back to passthrough).
BadRequest(String)
Client sent a malformed request.
Proxy-level auth failed.
RateLimited
Rate limit exceeded.
CircuitOpen
Circuit breaker is open — channel is unavailable.
Internal(Error)
Internal error (DB, config, unexpected).
Implementations§
Source§impl ProxyError
impl ProxyError
Sourcepub fn to_response(&self) -> Response
pub fn to_response(&self) -> Response
Converts this error into an HTTP response.
Maps each variant to the appropriate status code and sanitized JSON body. Internal details are stripped from the client-facing response.
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Returns the HTTP status code for this error.
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Returns the machine-readable error code.
Trait Implementations§
Source§impl Debug for ProxyError
impl Debug for ProxyError
Source§impl Display for ProxyError
impl Display for ProxyError
Source§impl Error for ProxyError
impl Error for ProxyError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()