Struct cosworth::prelude::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§
source§impl<T> InternalError<T>
impl<T> InternalError<T>
sourcepub fn new(cause: T, status: StatusCode) -> InternalError<T>
pub fn new(cause: T, status: StatusCode) -> InternalError<T>
Create InternalError
instance
sourcepub fn from_response(cause: T, response: HttpResponse) -> InternalError<T>
pub fn from_response(cause: T, response: HttpResponse) -> InternalError<T>
Create InternalError
with predefined HttpResponse
.
Trait Implementations§
source§impl<T> Fail for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
impl<T> Fail for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
source§fn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
Returns a reference to the
Backtrace
carried by this failure, if it
carries one. Read more§fn 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
source§impl<T> Responder for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
impl<T> Responder for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
§type Item = HttpResponse
type Item = HttpResponse
The associated item which can be returned.
source§fn 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
.source§impl<T> ResponseError for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
impl<T> ResponseError for InternalError<T>where
T: 'static + Send + Sync + Debug + Display,
source§fn 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§
§impl<T> AsFail for Twhere
T: Fail,
impl<T> AsFail for Twhere
T: Fail,
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
Convert
&self
to an expression for Diesel’s query builder. Read more