Struct actix_web::error::InternalError
source · 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.
use actix_web::fs::NamedFile;
fn index(req: HttpRequest) -> Result<fs::NamedFile> {
let f = NamedFile::open("test.txt").map_err(error::ErrorBadRequest)?;
Ok(f)
}
Implementations
sourceimpl<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: HttpResponse) -> Self
pub fn from_response(cause: T, response: HttpResponse) -> Self
Create InternalError
with predefined HttpResponse
.
Trait Implementations
sourceimpl<T> Fail for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
impl<T> Fail for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
Returns a reference to the
Backtrace
carried by this failure, if it
carries one. Read moresourcefn cause(&self) -> Option<&(dyn Fail + 'static)>
fn cause(&self) -> Option<&(dyn Fail + 'static)>
Returns a reference to the underlying cause of this failure, if it
is an error that wraps other errors. Read more
sourceimpl<T> Responder for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
impl<T> Responder for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
type Item = HttpResponse
type Item = HttpResponse
The associated item which can be returned.
sourcefn respond_to<S>(self, _: &HttpRequest<S>) -> Result<HttpResponse, Error>
fn respond_to<S>(self, _: &HttpRequest<S>) -> Result<HttpResponse, Error>
Convert itself to
AsyncResult
or Error
.sourceimpl<T> ResponseError for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
impl<T> ResponseError for InternalError<T>where
T: Send + Sync + Debug + Display + 'static,
sourcefn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Create response for error Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for InternalError<T>
impl<T> Send for InternalError<T>where
T: Send,
impl<T> Sync for InternalError<T>where
T: Sync,
impl<T> Unpin for InternalError<T>where
T: Unpin,
impl<T> UnwindSafe for InternalError<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more