pub enum PurwaError {
Validation(ValidationErrors),
MalformedJson(String),
MalformedForm(String),
Unauthorized {
message: String,
},
Forbidden {
message: String,
},
NotFound {
message: String,
},
Database(Error),
Internal {
message: String,
},
}Expand description
Central framework error type.
Variants§
Validation(ValidationErrors)
Field validation failed (validator::Validate); 422.
MalformedJson(String)
JSON body could not be parsed or did not match the DTO; 400.
MalformedForm(String)
Form or query deserialization failed; 400.
Session or credentials missing; 401.
Fields
Forbidden
Authenticated but not allowed; 403.
NotFound
Resource not found; 404.
Database(Error)
Database layer failure; 500 (details logged, not echoed).
Internal
Generic server error; 500 (message is safe for clients).
Implementations§
Source§impl PurwaError
impl PurwaError
pub fn forbidden(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Sourcepub fn from_json_rejection(rejection: JsonRejection) -> Self
pub fn from_json_rejection(rejection: JsonRejection) -> Self
Convert Axum’s JsonRejection into 400 PurwaError::MalformedJson.
Sourcepub fn from_form_rejection(rejection: FormRejection) -> Self
pub fn from_form_rejection(rejection: FormRejection) -> Self
Convert Axum’s FormRejection into 400 PurwaError::MalformedForm.
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
HTTP status for this error.
Sourcepub fn inertia_error_props(&self) -> Value
pub fn inertia_error_props(&self) -> Value
JSON value merged into Inertia page props for the shared Error page component.
Sourcepub fn validation_errors_map_json(&self) -> Map<String, Value>
pub fn validation_errors_map_json(&self) -> Map<String, Value>
Flat errors object for Inertia (empty unless validation).
Trait Implementations§
Source§impl Debug for PurwaError
impl Debug for PurwaError
Source§impl Display for PurwaError
impl Display for PurwaError
Source§impl Error for PurwaError
impl Error for PurwaError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<Error> for PurwaError
impl From<Error> for PurwaError
Source§impl From<ValidationErrors> for PurwaError
impl From<ValidationErrors> for PurwaError
Source§fn from(source: ValidationErrors) -> Self
fn from(source: ValidationErrors) -> Self
Converts to this type from the input type.
Source§impl IntoResponse for PurwaError
impl IntoResponse for PurwaError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl Freeze for PurwaError
impl !RefUnwindSafe for PurwaError
impl Send for PurwaError
impl Sync for PurwaError
impl Unpin for PurwaError
impl UnsafeUnpin for PurwaError
impl !UnwindSafe for PurwaError
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP