ErrorCode

Trait ErrorCode 

Source
pub trait ErrorCode: Copy + Eq {
    const ERROR_CODE_MAX: usize;
    const PREFIX: &'static str = "E";

    // Required methods
    fn code(self) -> usize;
    fn description(self) -> &'static str;
}
Expand description

Error codes of an application.

This is intended to be implemented by a flat enum in an application that defines all of its errors.

Required Associated Constants§

Source

const ERROR_CODE_MAX: usize

Returns the largest possible error code value.

This is used to determine the number of leading 0s when formatting the error message.

Provided Associated Constants§

Source

const PREFIX: &'static str = "E"

Returns the &str to prefix the error code – the "E" in "E001".

Defaults to "E".

Required Methods§

Source

fn code(self) -> usize

Returns the error code.

Source

fn description(self) -> &'static str

Returns a short description of the error.

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§