#[non_exhaustive]pub enum GenericErrorCode {
Show 22 variants
InternalError,
ValidationFailed,
NotFound,
Conflict,
Unauthorized,
Forbidden,
Gone,
PaymentRequired,
MethodNotAllowed,
NotAcceptable,
RequestTimeout,
PreconditionFailed,
PayloadTooLarge,
UnsupportedMediaType,
UnprocessableEntity,
Locked,
PreconditionRequired,
TooManyRequests,
NotImplemented,
ServiceUnavailable,
GatewayTimeout,
Other(u16),
}Expand description
Generic error codes for common scenarios.
Use these when a domain-specific error code is not available.
§Error indexes
The six historical variants keep their original indexes (0-6) so existing
internalCode values stay stable. Every variant added later uses its HTTP
status code as index, which makes the internal code self-describing
(UnprocessableEntity -> 1422, TooManyRequests -> 1429).
Other is the catch-all for any status without a dedicated variant: it
carries the status verbatim so nothing is ever silently degraded to 500.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InternalError
ValidationFailed
NotFound
Conflict
Forbidden
Gone
PaymentRequired
MethodNotAllowed
NotAcceptable
RequestTimeout
PreconditionFailed
PayloadTooLarge
UnsupportedMediaType
UnprocessableEntity
Locked
PreconditionRequired
TooManyRequests
NotImplemented
GatewayTimeout
Other(u16)
Any other HTTP status, kept verbatim (e.g. Other(418) ->
GENERIC_HTTP_418, internal code 1418, status 418).
Trait Implementations§
Source§impl Clone for GenericErrorCode
impl Clone for GenericErrorCode
Source§fn clone(&self) -> GenericErrorCode
fn clone(&self) -> GenericErrorCode
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 GenericErrorCode
Source§impl CqrsErrorCode for GenericErrorCode
impl CqrsErrorCode for GenericErrorCode
Source§fn domain_prefix() -> u16
fn domain_prefix() -> u16
Source§fn error_index(&self) -> u16
fn error_index(&self) -> u16
Source§fn http_status(&self) -> StatusCode
fn http_status(&self) -> StatusCode
Source§fn internal_code(&self) -> u16
fn internal_code(&self) -> u16
Source§fn code_string(&self) -> String
fn code_string(&self) -> String
Source§impl Debug for GenericErrorCode
impl Debug for GenericErrorCode
Source§impl Display for GenericErrorCode
impl Display for GenericErrorCode
impl Eq for GenericErrorCode
Source§impl Error for GenericErrorCode
impl Error for GenericErrorCode
1.30.0 · 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()
Source§impl From<StatusCode> for GenericErrorCode
impl From<StatusCode> for GenericErrorCode
Source§fn from(status: StatusCode) -> Self
fn from(status: StatusCode) -> Self
Maps an HTTP status to its dedicated variant, falling back to
GenericErrorCode::Other — which preserves the status — instead of
degrading unknown statuses to 500.