pub enum Error {
ConfigMissingEnv(&'static str),
Auth(Error),
User(Error),
DailyChallenge(Error),
SerdeJson(Error),
JsonRejection(JsonRejection),
}
Expand description
Main Error Types for all axum handlers.
This contains all of the error types from all other modules.
In particular, the From
trait is used to cast the error types from other modules to this.
Moreover, This handles the following:
- Error types from serde_json, if an axum handler fails to serialize to JSON as a response.
- JSON Rejection errors from [axum][
axum::extract::rejection::JsonRejection
], if an axum handler fails to deserialize the request body to JSON. This occurs if the consumer of the API sends a malformed/incorrect format for the request body. - Error types from auth.
- Error types from users.
Variants§
ConfigMissingEnv(&'static str)
This error will occur if an environment variable imported using
get_env()
is missing when the server starts up.
If you want to import env variables with default value such as PORT
, you can use
get_env_opt()
instead.
Auth(Error)
Errors from auth::Error
User(Error)
Errors from auth::Error
DailyChallenge(Error)
SerdeJson(Error)
Errors from serde_json::Error
JsonRejection(JsonRejection)
This error will occur if a request body is not valid JSON.
Implementations§
Source§impl Error
impl Error
Sourcepub fn client_status_error(&self) -> (StatusCode, ClientError)
pub fn client_status_error(&self) -> (StatusCode, ClientError)
Maps the injected server error of type Error
to a client error ClientError
.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl IntoResponse for Error
impl IntoResponse for Error
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Initializes errors to client errors with INTERNAL_SERVER_ERROR
and injects the server error into the
request through the use of extensions.
The injected server error will be retrieved later on and will be mapped to a proper client error.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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