pub struct InternalError<T> { /* private fields */ }Expand description
Wraps errors to alter the generated response status code.
In following example, the io::Error is wrapped into ErrorBadRequest which will generate a
response with the 400 Bad Request status code instead of the usual status code generated by
an io::Error.
§Examples
async fn handler_error() -> Result<String, actix_web::Error> {
    let err = io::Error::new(io::ErrorKind::Other, "error");
    Err(error::ErrorBadRequest(err))
}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
Constructs an InternalError with given status code.
Sourcepub fn from_response(cause: T, response: HttpResponse) -> Self
 
pub fn from_response(cause: T, response: HttpResponse) -> Self
Constructs an InternalError with pre-defined response.
Trait Implementations§
Source§impl<T: Debug> Debug for InternalError<T>
 
impl<T: Debug> Debug for InternalError<T>
Source§impl<T: Display> Display for InternalError<T>
 
impl<T: Display> Display for InternalError<T>
Source§impl<T> Responder for InternalError<T>
 
impl<T> Responder for InternalError<T>
type Body = BoxBody
Source§fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body>
 
fn respond_to(self, _: &HttpRequest) -> HttpResponse<Self::Body>
Convert self to 
HttpResponse.Source§impl<T> ResponseError for InternalError<T>
 
impl<T> ResponseError for InternalError<T>
Source§fn status_code(&self) -> StatusCode
 
fn status_code(&self) -> StatusCode
Returns appropriate status code for error. Read more
Source§fn error_response(&self) -> HttpResponse
 
fn error_response(&self) -> HttpResponse
Creates full response for error. 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> 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