pub struct RespErr {
pub status_code: StatusCode,
/* private fields */
}Expand description
An error to be used as the error variant of a request handler.
Often initialized by using RespErrCtx::ctx on Result, Option or Response.
But it can also be initialized by RespErr::new.
§Examples
use axum_ctx::*;
fn can_fail() -> Result<(), std::io::Error> {
// …
}
async fn get() -> Result<StatusCode, RespErr> {
can_fail()
.ctx(StatusCode::INTERNAL_SERVER_ERROR)
.user_msg("Sorry for disappointing you. Do you want a cookie?")
.log_msg("Failed to do …. Blame Max Mustermann")?;
// …
Ok(StatusCode::OK)
}Using the type alias RespResult is recommended:
async fn get() -> RespResult<StatusCode> {
// …
}Fields§
§status_code: StatusCodeImplementations§
Trait Implementations§
Source§impl IntoResponse for RespErr
impl IntoResponse for RespErr
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Log the error, set the HTTP status code and return the response.
Auto Trait Implementations§
impl Freeze for RespErr
impl !RefUnwindSafe for RespErr
impl Send for RespErr
impl !Sync for RespErr
impl Unpin for RespErr
impl !UnwindSafe for RespErr
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
Mutably borrows from an owned value. Read more