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
Create InternalError
instance
Create InternalError
instance
Create InternalError
with predefined Response
.
Trait Implementations
impl<T, Err> Responder<Err> for InternalError<T, Err> where
T: Debug + Display + 'static,
Err: ErrorRenderer,
impl<T, Err> Responder<Err> for InternalError<T, Err> where
T: Debug + Display + 'static,
Err: ErrorRenderer,
Convert itself to AsyncResult
or Error
.
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>,
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>,
Add header to the Responder’s response. Read more
impl<T, E> ResponseError for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
impl<T, E> ResponseError for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
Create response for error Read more
impl<T, E> WebResponseError<E> for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
impl<T, E> WebResponseError<E> for InternalError<T, E> where
T: Debug + Display + 'static,
E: ErrorRenderer,
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,
impl<T, Err = DefaultError> !UnwindSafe for InternalError<T, Err>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more