Skip to main content

ErrorCategory

Trait ErrorCategory 

Source
pub trait ErrorCategory:
    Copy
    + Into<ErrorCode>
    + From<ErrorCode>
    + Debug {
    type L0: ErrorCategory;
    type L1: ErrorCategory;
    type L2: ErrorCategory;
    type L3: ErrorCategory;
    type L4: ErrorCategory;
    type L5: ErrorCategory;

    const NAME: &'static str;

    // Provided method
    fn chainable_category_formatters() -> &'static [ErrorCodeFormatter] { ... }
}
Expand description

A trait that implements the logic for debug printing and ErrorCode conversion. It also specifies the links to other error categories that allows errors of different categories to be chained.

Note: Only up to 6 linked error categories are supported.

See Error, DynError and ErrorData for more information.

Required Associated Constants§

Source

const NAME: &'static str

The text name of this category used for formatting.

Required Associated Types§

Source

type L0: ErrorCategory

Type of linked error category 0.

Set to Unused if unused.

Source

type L1: ErrorCategory

Type of linked error category 1.

Set to Unused if unused.

Source

type L2: ErrorCategory

Type of linked error category 2.

Set to Unused if unused.

Source

type L3: ErrorCategory

Type of linked error category 3.

Set to Unused if unused.

Source

type L4: ErrorCategory

Type of linked error category 4.

Set to Unused if unused.

Source

type L5: ErrorCategory

Type of linked error category 5.

Set to Unused if unused.

Provided Methods§

Source

fn chainable_category_formatters() -> &'static [ErrorCodeFormatter]

Get a slice of all ErrorCodeFormatter functions for all error categories that this error category is linked to.

Specifically returns a slice of function pointers to the error code formatter function of Self::L0 up to Self::L5. Each element in the returned slice corresponds to the formatter function of the error category type Self::Lx where x is the index of the element. The slice can be smaller than 6 elements, if the excluded linked error categories are unused (i.e. Self::Lx is set to Unused).

All formatter functions contained in the returned slice must have identical behavior to format_chained() with the exception that the formatting can differ.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§