pub enum Error {
Show 17 variants
Http(String),
Status(u16, String),
Unauthorized(String),
Forbidden(String),
Di(String),
Routing(String),
Serialization(Error),
ResponseSerialization(Error),
State(String),
Internal(String),
Message(String),
Validation(String),
NotFound(String),
Conflict(String),
PayloadTooLarge(String),
UnsupportedMediaType(String),
Problem(Box<ProblemDetails>),
}Expand description
Framework-wide error type.
Variants§
Http(String)
Status(u16, String)
Forbidden(String)
Di(String)
Routing(String)
Serialization(Error)
ResponseSerialization(Error)
Serializing the response failed — a server-side defect, not a bad request.
Kept separate from Error::Serialization (which stays on the request
parsing path and maps to 400) so that a DTO which cannot be serialized
is reported as 500 instead of blaming the client. There is no #[from]
because that conversion is already taken by Serialization; call sites
convert explicitly with .map_err(Error::ResponseSerialization).
State(String)
A server-side state-machine / programming error, e.g. the response body state does not allow the requested operation. Maps to 500.
Internal(String)
Message(String)
Validation(String)
Validation error with user-readable message.
NotFound(String)
Resource not found.
Conflict(String)
Optimistic concurrency or state conflict.
PayloadTooLarge(String)
Request body (or one uploaded file) exceeded the configured limit.
UnsupportedMediaType(String)
Request content type is not supported by the target endpoint.
Problem(Box<ProblemDetails>)
A fully-formed problem response (validation, binding failure).
Carried as-is instead of being flattened into a message so the host can
write the status and the extension members (errors) verbatim.
Implementations§
Source§impl Error
impl Error
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Map the error to an appropriate HTTP status code.
Used by the built-in exception middleware to produce well-formed HTTP error responses.
Sourcepub fn public_detail(&self) -> Option<&str>
pub fn public_detail(&self) -> Option<&str>
The client-facing detail for a 4xx response.
Display is written for operators ("Unauthorized: …",
"Internal error: …"), so serving it verbatim would leak variant names
and internals. This returns the variant’s own message for the errors
that are safe to show, and None for 5xx/internal variants — the host
then serves a stable detail and logs the original text.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()