Struct tusk_rs::reqres::RouteError
source · pub struct RouteError {
pub message: String,
pub status_code: ResponseStatusCode,
pub override_output: bool,
}
Expand description
RouteError is a struct that lets Tusk know
that something went wrong in your application.
It automatically can handle simple String
s as errors,
but a custom String
can be provided by using the custom
method.
If the default implementation is used, the response returns
in this format:
{ code: HTTP CODE, message: "your_message" }
Fields§
§message: String
§status_code: ResponseStatusCode
§override_output: bool
Implementations§
source§impl RouteError
impl RouteError
sourcepub fn bad_request(msg: &str) -> RouteError
pub fn bad_request(msg: &str) -> RouteError
Sends a 400 error with a message.
sourcepub fn forbidden(msg: &str) -> RouteError
pub fn forbidden(msg: &str) -> RouteError
Sends a 403 error with a message.
sourcepub fn not_found(msg: &str) -> RouteError
pub fn not_found(msg: &str) -> RouteError
Sends a 404 error with a message.
sourcepub fn conflict(msg: &str) -> RouteError
pub fn conflict(msg: &str) -> RouteError
Sends a 409 error with a message.
sourcepub fn server_error(msg: &str) -> RouteError
pub fn server_error(msg: &str) -> RouteError
Sends a 500 error with a message.
sourcepub fn custom(msg: &str, status_code: ResponseStatusCode) -> RouteError
pub fn custom(msg: &str, status_code: ResponseStatusCode) -> RouteError
Return a custom error message. The string provided is directly sent with no formatting. A status code is also provided.
pub fn to_response(self) -> Response
Trait Implementations§
source§impl Debug for RouteError
impl Debug for RouteError
source§impl From<JsonParseError> for RouteError
impl From<JsonParseError> for RouteError
source§fn from(val: JsonParseError) -> Self
fn from(val: JsonParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RouteError
impl RefUnwindSafe for RouteError
impl Send for RouteError
impl Sync for RouteError
impl Unpin for RouteError
impl UnwindSafe for RouteError
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