Trait tide_disco::error::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

Object Safety§

This trait is not object safe.

Implementors§