Skip to main content

ErrorCode

Trait ErrorCode 

Source
pub trait ErrorCode:
    Debug
    + Send
    + Sync {
    // Required methods
    fn code(&self) -> &str;
    fn status(&self) -> u16;
    fn title(&self) -> &str;

    // Provided method
    fn description(&self) -> &str { ... }
}
Expand description

A machine-readable error code with the HTTP status it is sent with and a short title. An application implements it for its own codes, such as invoice_not_finalised.

Required Methods§

Source

fn code(&self) -> &str

The code, such as invalid_api_version.

Source

fn status(&self) -> u16

The HTTP status the code is sent with.

Source

fn title(&self) -> &str

A short, human-readable summary that does not change between occurrences.

Provided Methods§

Source

fn description(&self) -> &str

What the code means, for the OpenAPI document. Empty leaves it at the title.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§