pub enum FrameworkError {
ServiceNotFound {
type_name: &'static str,
},
ParamError {
param_name: String,
},
ValidationError {
field: String,
message: String,
},
DatabaseError {
message: String,
},
Internal {
message: String,
},
}Expand description
Framework-wide error type
This enum represents all possible errors that can occur in the framework.
It implements From<FrameworkError> for Response so errors can be propagated
using the ? operator in controller handlers.
§Example
ⓘ
use kit::{App, FrameworkError, Response};
pub async fn index(_req: Request) -> Response {
let service = App::resolve::<MyService>()?; // Returns FrameworkError on failure
// ...
}Variants§
ServiceNotFound
Service not found in the dependency injection container
ParamError
Parameter extraction failed (missing or invalid parameter)
ValidationError
Validation error
DatabaseError
Database error
Internal
Generic internal server error
Implementations§
Source§impl FrameworkError
impl FrameworkError
Sourcepub fn service_not_found<T: ?Sized>() -> Self
pub fn service_not_found<T: ?Sized>() -> Self
Create a ServiceNotFound error for a given type
Sourcepub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
Create a ValidationError
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Get the HTTP status code for this error
Trait Implementations§
Source§impl Clone for FrameworkError
impl Clone for FrameworkError
Source§fn clone(&self) -> FrameworkError
fn clone(&self) -> FrameworkError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FrameworkError
impl Debug for FrameworkError
Source§impl Display for FrameworkError
impl Display for FrameworkError
Source§impl Error for FrameworkError
impl Error for FrameworkError
1.30.0 · 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<FrameworkError> for HttpResponse
Auto-convert FrameworkError to HttpResponse
impl From<FrameworkError> for HttpResponse
Auto-convert FrameworkError to HttpResponse
This enables using the ? operator in controller handlers to propagate
framework errors as appropriate HTTP responses.
Source§fn from(err: FrameworkError) -> HttpResponse
fn from(err: FrameworkError) -> HttpResponse
Converts to this type from the input type.
Source§impl From<ParamError> for FrameworkError
impl From<ParamError> for FrameworkError
Source§fn from(err: ParamError) -> FrameworkError
fn from(err: ParamError) -> FrameworkError
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for FrameworkError
impl RefUnwindSafe for FrameworkError
impl Send for FrameworkError
impl Sync for FrameworkError
impl Unpin for FrameworkError
impl UnwindSafe for FrameworkError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more