Struct gotham::handler::HandlerError [−][src]
Describes an error which occurred during handler execution, and allows the creation of a HTTP
Response
.
Implementations
impl HandlerError
[src]
pub fn status(&self) -> StatusCode
[src]
Returns the HTTP status code associated with this HandlerError
.
pub fn with_status(self, status_code: StatusCode) -> HandlerError
[src]
Sets the HTTP status code of the response which is generated by the IntoResponse
implementation.
fn handler(state: State) -> Pin<Box<HandlerFuture>> { // It's OK if this is bogus, we just need something to convert into a `HandlerError`. let io_error = std::io::Error::last_os_error(); let handler_error = HandlerError::from(io_error) .with_status(StatusCode::IM_A_TEAPOT); future::err((state, handler_error)).boxed() } let test_server = TestServer::new(|| Ok(handler)).unwrap(); let response = test_server.client().get("http://example.com/").perform().unwrap(); assert_eq!(response.status(), StatusCode::IM_A_TEAPOT);
pub fn downcast_cause_ref<E>(&self) -> Option<&E> where
E: Display + Debug + Send + Sync + 'static,
[src]
E: Display + Debug + Send + Sync + 'static,
Attempt to downcast the cause by reference.
pub fn downcast_cause_mut<E>(&mut self) -> Option<&mut E> where
E: Display + Debug + Send + Sync + 'static,
[src]
E: Display + Debug + Send + Sync + 'static,
Attempt to downcast the cause by mutable reference.
Trait Implementations
impl Debug for HandlerError
[src]
impl<E> From<E> for HandlerError where
E: Into<Error> + Display,
[src]
E: Into<Error> + Display,
Convert a generic anyhow::Error
into a HandlerError
, similar as you would a concrete error
type with into_handler_error()
.
fn from(error: E) -> HandlerError
[src]
impl IntoResponse for HandlerError
[src]
fn into_response(self, state: &State) -> Response<Body>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for HandlerError
impl Send for HandlerError
impl Sync for HandlerError
impl Unpin for HandlerError
impl !UnwindSafe for HandlerError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,