pub enum ErrorCode {
Show 13 variants
NotFound,
Forbidden,
PolicyUnavailable,
MissingTenant,
InvalidAttribute,
InvalidParameter,
Conflict,
PreconditionFailed,
LockContention,
Closing,
Unsupported,
UnsupportedMediaType,
Internal,
}Expand description
The JSON:API code values this crate emits, and the HTTP status each
carries.
Variants§
NotFound
UnknownResource / UnknownAction / NotFound.
Forbidden
A deliberate policy denial.
A policy outage — distinct from a denial, and retriable.
MissingTenant
InvalidAttribute
A validation failure on a specific attribute.
InvalidParameter
A malformed or unknown query parameter — an unknown sort attribute, filter key or include path, or two pagination strategies at once. Resolved against the schema before the data layer is touched.
Conflict
Optimistic-concurrency failure; retriable.
PreconditionFailed
The If-Match precondition was supplied and stale.
LockContention
Closing
The domain is draining. A lifecycle signal, not a fault.
Unsupported
UnsupportedMediaType
The request body was not sent as application/vnd.api+json.
JSON:API requires the media type on any request carrying a document,
and requires 415 when it is missing — a body sent as
application/json is refused rather than guessed at.
Internal
DataLayer / Serialization. The message is never surfaced.
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn status(self) -> StatusCode
pub fn status(self) -> StatusCode
The HTTP status for this code.
Sourcepub fn title(self) -> &'static str
pub fn title(self) -> &'static str
A short, human-readable title. Safe to show a client.
Not StatusCode::canonical_reason(): three of these codes are 503,
and “Service Unavailable” would collapse the distinction between a
policy outage, lock contention and a draining server that the codes exist
to preserve.
Sourcepub fn is_retriable(self) -> bool
pub fn is_retriable(self) -> bool
Whether the client may retry. Drives Retry-After.
Sourcepub fn is_sanitized(self) -> bool
pub fn is_sanitized(self) -> bool
Whether the underlying error’s message must be withheld from the response body.