Struct ntex::web::error::InternalError [−][src]
pub struct InternalError<T, Err = DefaultError> { /* fields omitted */ }
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 ntex::http::Request; fn index(req: Request) -> Result<&'static str, std::io::Error> { Err(std::io::Error::new(std::io::ErrorKind::Other, "error")) }
Implementations
impl<T> InternalError<T>
[src]
impl<T> InternalError<T>
[src]pub fn default(cause: T, status: StatusCode) -> Self
[src]
pub fn default(cause: T, status: StatusCode) -> Self
[src]Create InternalError
instance
impl<T, Err> InternalError<T, Err>
[src]
impl<T, Err> InternalError<T, Err>
[src]pub fn new(cause: T, status: StatusCode) -> Self
[src]
pub fn new(cause: T, status: StatusCode) -> Self
[src]Create InternalError
instance
pub fn from_response(cause: T, response: HttpResponse) -> Self
[src]
pub fn from_response(cause: T, response: HttpResponse) -> Self
[src]Create InternalError
with predefined Response
.
Trait Implementations
impl<T, E> Debug for InternalError<T, E> where
T: Debug + 'static,
[src]
impl<T, E> Debug for InternalError<T, E> where
T: Debug + 'static,
[src]impl<T, E> Display for InternalError<T, E> where
T: Display + 'static,
[src]
impl<T, E> Display for InternalError<T, E> where
T: Display + 'static,
[src]impl<T, Err> Responder<Err> for InternalError<T, Err> where
T: Debug + Display + 'static,
Err: ErrorRenderer,
[src]
impl<T, Err> Responder<Err> for InternalError<T, Err> where
T: Debug + Display + 'static,
Err: ErrorRenderer,
[src]fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]
fn respond_to(self, req: &HttpRequest) -> Self::Future
[src]Convert itself to AsyncResult
or Error
.
fn with_status(self, status: StatusCode) -> CustomResponder<Self, Err> where
Self: Sized,
[src]
fn with_status(self, status: StatusCode) -> CustomResponder<Self, Err> where
Self: Sized,
[src]Override a status code for a Responder. Read more
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, Err> where
Self: Sized,
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
[src]
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, Err> where
Self: Sized,
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
[src]Add header to the Responder’s response. Read more
impl<T, E> ResponseError for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
[src]
impl<T, E> ResponseError for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
[src]fn error_response(&self) -> HttpResponse
[src]
fn error_response(&self) -> HttpResponse
[src]Create response for error Read more
impl<T, E> WebResponseError<E> for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
[src]
impl<T, E> WebResponseError<E> for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
[src]fn error_response(&self, _: &HttpRequest) -> HttpResponse
[src]
fn error_response(&self, _: &HttpRequest) -> HttpResponse
[src]Generate response for error Read more
fn status_code(&self) -> StatusCode
[src]
fn status_code(&self) -> StatusCode
[src]Response’s status code Read more
Auto Trait Implementations
impl<T, Err = DefaultError> !RefUnwindSafe for InternalError<T, Err>
impl<T, Err = DefaultError> !Send for InternalError<T, Err>
impl<T, Err = DefaultError> !Sync for InternalError<T, Err>
impl<T, Err> Unpin for InternalError<T, Err> where
Err: Unpin,
T: Unpin,
Err: Unpin,
T: Unpin,
impl<T, Err = DefaultError> !UnwindSafe for InternalError<T, Err>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self