pub enum StandardErrorCode {
Show 13 variants
InvalidRequest,
Authentication,
PermissionDenied,
NotFound,
RequestTooLarge,
RateLimited,
QuotaExhausted,
ServerError,
Overloaded,
Timeout,
Conflict,
Cancelled,
Unknown,
}Expand description
Standard AI-Protocol V2 error code.
Each variant corresponds to a canonical error from the specification, with associated metadata: code string, name, retryable, and fallbackable flags.
Variants§
InvalidRequest
E1001: Malformed request, invalid parameters, or missing required fields
Authentication
E1002: Invalid, expired, or missing API key
PermissionDenied
E1003: Valid credentials but insufficient permissions
NotFound
E1004: Requested model, endpoint, or resource does not exist
RequestTooLarge
E1005: Input exceeds context window or API payload size limit
RateLimited
E2001: Request rate limit exceeded
QuotaExhausted
E2002: Account usage quota or billing limit reached
ServerError
E3001: Internal server error on provider side
Overloaded
E3002: Provider service temporarily overloaded
Timeout
E3003: Request timed out before response received
Conflict
E4001: State conflict (e.g., concurrent modification)
Cancelled
E4002: Request was cancelled by the client
Unknown
E9999: Error could not be classified
Implementations§
Source§impl StandardErrorCode
impl StandardErrorCode
Sourcepub fn fallbackable(&self) -> bool
pub fn fallbackable(&self) -> bool
Returns whether this error should trigger a fallback to another provider.
Sourcepub fn category(&self) -> &'static str
pub fn category(&self) -> &'static str
Returns the category: "client", "rate", "server", "operational", or "unknown".
Sourcepub fn from_provider_code(provider_code: &str) -> Option<Self>
pub fn from_provider_code(provider_code: &str) -> Option<Self>
Maps a provider error code/type string to the corresponding StandardErrorCode.
Supports both standard names (e.g., "invalid_request") and provider-specific
aliases such as "invalid_api_key", "context_length_exceeded", "overloaded_error".
Sourcepub fn from_error_class(error_class: &str) -> Self
pub fn from_error_class(error_class: &str) -> Self
Maps an error class name string to the corresponding StandardErrorCode.
The class name should match the standard names (e.g., "invalid_request").
Aliases such as "authorized_error" (→ authentication) are supported.
Unknown class names map to StandardErrorCode::Unknown.
Sourcepub fn from_http_status(status: u16) -> Self
pub fn from_http_status(status: u16) -> Self
Maps an HTTP status code to the most likely StandardErrorCode.
Multiple status codes can map to the same error (e.g., 429 → rate_limited).
Status codes without a standard mapping return StandardErrorCode::Unknown.
Trait Implementations§
Source§impl Clone for StandardErrorCode
impl Clone for StandardErrorCode
Source§fn clone(&self) -> StandardErrorCode
fn clone(&self) -> StandardErrorCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StandardErrorCode
impl Debug for StandardErrorCode
Source§impl Display for StandardErrorCode
impl Display for StandardErrorCode
Source§impl Hash for StandardErrorCode
impl Hash for StandardErrorCode
Source§impl PartialEq for StandardErrorCode
impl PartialEq for StandardErrorCode
impl Copy for StandardErrorCode
impl Eq for StandardErrorCode
impl StructuralPartialEq for StandardErrorCode
Auto Trait Implementations§
impl Freeze for StandardErrorCode
impl RefUnwindSafe for StandardErrorCode
impl Send for StandardErrorCode
impl Sync for StandardErrorCode
impl Unpin for StandardErrorCode
impl UnsafeUnpin for StandardErrorCode
impl UnwindSafe for StandardErrorCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.