Skip to main content

RokException

Trait RokException 

Source
pub trait RokException:
    Error
    + Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn status_code(&self) -> u16;

    // Provided methods
    fn self_handled(&self) -> bool { ... }
    fn translation_id(&self) -> Option<&'static str> { ... }
    fn help(&self) -> Option<&'static str> { ... }
}
Expand description

Base trait for all typed exceptions in the rok ecosystem.

Analogous to AdonisJS Exception — every crate exposes E_* structs implementing this trait. Self-handled exceptions can convert themselves to an HTTP response; non-self-handled ones must be caught by a global error handler.

Required Methods§

Source

fn name(&self) -> &'static str

Exception identifier (e.g. "E_ROW_NOT_FOUND").

Source

fn status_code(&self) -> u16

HTTP status code.

Provided Methods§

Source

fn self_handled(&self) -> bool

Whether this exception can produce its own HTTP response.

Source

fn translation_id(&self) -> Option<&'static str>

Optional i18n translation key.

Source

fn help(&self) -> Option<&'static str>

Optional help text for debugging.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§