pub enum ResponseError {
InternalServerError(Box<dyn DowncastableError>),
StatusCodeError {
code: StatusCode,
message: String,
},
}
Expand description
This type facilitates propagation of both internal server errors and status code errors. The former take place when something goes wrong in the backend that isn’t due to user error but nonetheless prevents a normal response (e.g. error contacting the database, a file on the backend server was not found). The latter is when an error takes place in a function that corresponds to a particular response to the user, for example if a function is called to get a row from a database that does not exist a StatusCodeError variant may be emitted with a 404 Not Found, thus allowing the caller to simply propogate this error via ? to the route and thus to the user.
Variants§
InternalServerError(Box<dyn DowncastableError>)
StatusCodeError
Trait Implementations§
Source§impl Debug for ResponseError
impl Debug for ResponseError
Source§impl Display for ResponseError
impl Display for ResponseError
Source§impl<T: DowncastableError + 'static> From<T> for ResponseError
impl<T: DowncastableError + 'static> From<T> for ResponseError
Source§impl ResponseError for ResponseError
impl ResponseError for ResponseError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Response’s status code Read more
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Create response for error Read more
Auto Trait Implementations§
impl Freeze for ResponseError
impl !RefUnwindSafe for ResponseError
impl !Send for ResponseError
impl !Sync for ResponseError
impl Unpin for ResponseError
impl !UnwindSafe for ResponseError
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> 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