pub struct ErrorPage {
pub status: StatusCode,
pub message: String,
pub fields: Vec<FieldError>,
}Expand description
What an HTML error page may show: the status, a message safe for users, and validation errors.
Built for every Error rendered as HTML (the message of a 500 is
always Internal server error; details only go to the logs), and for
bodyless or plain-text error responses such as axum’s rejections, with
the status’s reason phrase as message. Templates given to error_page
receive it.
§Examples
use axum::{http::StatusCode, response::IntoResponse};
use ocre::{Error, ErrorPage};
let response = Error::NotFound.into_response();
let page = response.extensions().get::<ErrorPage>().unwrap();
assert_eq!((page.status, page.message.as_str()), (StatusCode::NOT_FOUND, "Not found"));Fields§
§status: StatusCodeHTTP status of the response, e.g. 404: {{ error.status.as_u16() }} in a template.
message: StringMessage for the user: Not found, Validation failed, a bad request’s own message…
fields: Vec<FieldError>Field errors of a 422 ({{ field.full_message() }}), empty otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ErrorPage
impl RefUnwindSafe for ErrorPage
impl Send for ErrorPage
impl Sync for ErrorPage
impl Unpin for ErrorPage
impl UnsafeUnpin for ErrorPage
impl UnwindSafe for ErrorPage
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