pub struct ApiError { /* private fields */ }Expand description
A structured API error. Serializes to { "error": { code, message } } with
the matching HTTP status.
Implementations§
Source§impl ApiError
impl ApiError
A 401 for a missing/blank credential.
Sourcepub fn not_implemented(message: impl Into<String>) -> Self
pub fn not_implemented(message: impl Into<String>) -> Self
A 501 for a capability this edge was not configured with.
Used when BYOK is requested but no key-encryption key is set: the edge
declines rather than falling back to storing a provider key in the
clear. 501 rather than 503 because it will not start working on
retry — it needs configuration.
Sourcepub fn conflict(message: impl Into<String>) -> Self
pub fn conflict(message: impl Into<String>) -> Self
A 409 for a request that conflicts with the tenant’s current state.
Sourcepub fn bad_gateway(message: impl Into<String>) -> Self
pub fn bad_gateway(message: impl Into<String>) -> Self
A 502 when an upstream the edge depends on could not be reached.
The detail is deliberately thin: an upstream error can embed the request URL and headers, and for the LLM broker those headers carry a tenant’s provider key.
Sourcepub fn llm_credential_missing(message: impl Into<String>) -> Self
pub fn llm_credential_missing(message: impl Into<String>) -> Self
A 409 llm_credential.missing — this namespace has no provider key.
Shares the code the data plane returns for the same condition (see
from_brain), so one code means one thing whichever surface produced
it, and a client’s handling works against both.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
A 404 for a resource this tenant has not created.
Sourcepub fn bad_request(message: impl Into<String>) -> Self
pub fn bad_request(message: impl Into<String>) -> Self
A 400 for a malformed request the edge itself rejects.
Sourcepub fn from_brain(err: &BrainError) -> Self
pub fn from_brain(err: &BrainError) -> Self
Map a Brain client error to the matching HTTP status. Transport faults and
unavailable/exhausted verdicts are 503; auth verdicts 401/403;
validation/not-found/conflict map directly; anything else is 502.