#[non_exhaustive]pub enum ErrorCategory {
BadRequest,
Unauthorized,
Forbidden,
NotFound,
UnprocessableEntity,
Conflict,
RateLimited,
Timeout,
Unavailable,
Internal,
}Expand description
A coarse classification every klauthed error maps onto.
The category is the single source of truth for cross-cutting policy — HTTP status, retryability, client-vs-server — so individual error types only have to answer “which category am I?” rather than re-deriving an HTTP code each.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BadRequest
Caller sent something invalid (validation, malformed input). 400.
Authentication is missing or invalid. 401.
Forbidden
Authenticated but not allowed. 403.
NotFound
The target resource does not exist. 404.
UnprocessableEntity
The request was structurally valid but semantically unprocessable —
e.g. a field value fails a business rule, a required relationship does
not exist, or a constraint would be violated. 422.
Distinct from BadRequest: the server
understood the request; it simply cannot be fulfilled as-is. Use this
for validation errors surfaced after successful parsing.
Conflict
The request conflicts with current state. 409.
RateLimited
The caller has been rate limited. 429.
Timeout
The operation timed out. 504.
A dependency (DB, cache, broker, upstream) is unavailable. 503.
Internal
An unexpected server-side fault. 500.
Implementations§
Source§impl ErrorCategory
impl ErrorCategory
Sourcepub fn http_status(&self) -> u16
pub fn http_status(&self) -> u16
The conventional HTTP status for this category.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the operation might succeed (transient conditions).
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Whether this represents a caller error (4xx) rather than a server fault.
Trait Implementations§
Source§impl Clone for ErrorCategory
impl Clone for ErrorCategory
Source§fn clone(&self) -> ErrorCategory
fn clone(&self) -> ErrorCategory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ErrorCategory
Source§impl Debug for ErrorCategory
impl Debug for ErrorCategory
Source§impl<'de> Deserialize<'de> for ErrorCategory
impl<'de> Deserialize<'de> for ErrorCategory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ErrorCategory
impl Display for ErrorCategory
impl Eq for ErrorCategory
Source§impl Hash for ErrorCategory
impl Hash for ErrorCategory
Source§impl PartialEq for ErrorCategory
impl PartialEq for ErrorCategory
Source§fn eq(&self, other: &ErrorCategory) -> bool
fn eq(&self, other: &ErrorCategory) -> bool
self and other values to be equal, and is used by ==.