Struct actix_web::error::InternalError
source · 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>where
T: Debug + Display + 'static,
impl<T> Responder for InternalError<T>where T: Debug + Display + 'static,
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>where
T: Debug + Display,
impl<T> ResponseError for InternalError<T>where T: Debug + Display,
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> !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