tide_disco::error

Trait Error

Source
pub trait Error:
    Error
    + Serialize
    + DeserializeOwned
    + Send
    + Sync
    + 'static {
    // Required methods
    fn catch_all(status: StatusCode, msg: String) -> Self;
    fn status(&self) -> StatusCode;

    // Provided methods
    fn from_io_error(source: IoError) -> Self { ... }
    fn from_config_error(source: ConfigError) -> Self { ... }
    fn from_route_error<E: Display>(source: RouteError<E>) -> Self { ... }
    fn from_request_error(source: RequestError) -> Self { ... }
    fn from_socket_error<E: Display>(source: SocketError<E>) -> Self { ... }
    fn into_tide_error(self) -> Error { ... }
    fn from_server_error(source: Error) -> Self { ... }
}
Expand description

Errors which can be serialized in a response body.

This trait can be used to define a standard error type returned by all API endpoints. When a request fails for any reason, the body of the response will contain a serialization of the error that caused the failure, upcasted into an anyhow::Error. If the error is an instance of the standard error type for that particular API, it can be deserialized and downcasted to this type on the client.

Other errors (those which don’t downcast to the API’s error type, such as errors generated from the [tide] framework) will be serialized as strings using their Display instance and encoded as an API error using the catch_all function.

Required Methods§

Source

fn catch_all(status: StatusCode, msg: String) -> Self

Source

fn status(&self) -> StatusCode

Provided Methods§

Source

fn from_io_error(source: IoError) -> Self

Source

fn from_config_error(source: ConfigError) -> Self

Source

fn from_route_error<E: Display>(source: RouteError<E>) -> Self

Source

fn from_request_error(source: RequestError) -> Self

Source

fn from_socket_error<E: Display>(source: SocketError<E>) -> Self

Source

fn into_tide_error(self) -> Error

Source

fn from_server_error(source: Error) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§