pub struct InternalError<T> { /* private fields */ }
Expand description
Helper type that can wrap any error and generate custom response.
In following example any io::Error
will be converted into “BAD REQUEST”
response as opposite to INTERNAL SERVER ERROR which is defined by
default.
fn index(req: Request) -> Result<&'static str> {
Err(error::ErrorBadRequest(io::Error::new(io::ErrorKind::Other, "error")))
}
Implementations§
Source§impl<T> InternalError<T>
impl<T> InternalError<T>
Sourcepub fn new(cause: T, status: StatusCode) -> Self
pub fn new(cause: T, status: StatusCode) -> Self
Create InternalError
instance
Sourcepub fn from_response(cause: T, response: Response) -> Self
pub fn from_response(cause: T, response: Response) -> Self
Create InternalError
with predefined Response
.
Trait Implementations§
Source§impl<T> Debug for InternalError<T>where
T: Debug + 'static,
impl<T> Debug for InternalError<T>where
T: Debug + 'static,
Source§impl<T> Display for InternalError<T>where
T: Display + 'static,
impl<T> Display for InternalError<T>where
T: Display + 'static,
Source§impl<T> ResponseError for InternalError<T>
impl<T> ResponseError for InternalError<T>
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Response’s status code Read more
Auto Trait Implementations§
impl<T> !Freeze for InternalError<T>
impl<T> !RefUnwindSafe for InternalError<T>
impl<T> !Send for InternalError<T>
impl<T> !Sync for InternalError<T>
impl<T> Unpin for InternalError<T>where
T: Unpin,
impl<T> !UnwindSafe for InternalError<T>
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