pub trait FailureMode {
    type ID: Hash + Eq;

    // Required method
    fn identify(&self) -> Self::ID;

    // Provided methods
    fn log_level(&self) -> LogLevel { ... }
    fn cooldown(&self) -> Duration { ... }
    fn display(&self) -> Option<String> { ... }
    fn log(&self) { ... }
}
Expand description

Something that can be logged in a sysfail handler

Required Associated Types§

source

type ID: Hash + Eq

Used to de-duplicate identical messages to avoid spamming the log.

Required Methods§

source

fn identify(&self) -> Self::ID

What constitutes “distinct” error types.

Provided Methods§

source

fn log_level(&self) -> LogLevel

👎Deprecated since 4.0.0: This is ignored

Deprecated: this is ignored.

source

fn cooldown(&self) -> Duration

How long an error must not be produced in order to be displayed again.

This controls when Failure::get_error returns an error.

Return Duration::ZERO to trigger Failure::get_error each time there is an error.

source

fn display(&self) -> Option<String>

👎Deprecated since 4.0.0: This crate now directly uses the fmt::Display impl on the error.

Deprecated, this does nothing.

source

fn log(&self)

What happens, by default this logs based on the return value of FailureMode::log_level.

Examples

https://crates.io/crates/bevy_debug_text_overlay provides a wrapper struct to replace log-printing with displaying errors on screen.

Implementations on Foreign Types§

source§

impl FailureMode for &'static str

source§

fn log_level(&self) -> LogLevel

👎Deprecated since 4.0.0: This is ignored
§

type ID = &'static str

source§

fn identify(&self) -> Self

source§

fn display(&self) -> Option<String>

👎Deprecated since 4.0.0: This crate now directly uses the fmt::Display impl on the error.
source§

impl FailureMode for ()

source§

fn log_level(&self) -> LogLevel

👎Deprecated since 4.0.0: This is ignored
§

type ID = ()

source§

fn identify(&self)

source§

fn display(&self) -> Option<String>

👎Deprecated since 4.0.0: This crate now directly uses the fmt::Display impl on the error.
source§

impl FailureMode for Box<dyn Error>

source§

fn identify(&self)

By default, only print a single error per system.

source§

fn log_level(&self) -> LogLevel

👎Deprecated since 4.0.0: This is ignored
§

type ID = ()

source§

fn display(&self) -> Option<String>

👎Deprecated since 4.0.0: This crate now directly uses the fmt::Display impl on the error.
source§

impl FailureMode for Error

source§

fn identify(&self)

By default, only print a single error per system.

source§

fn log_level(&self) -> LogLevel

👎Deprecated since 4.0.0: This is ignored
§

type ID = ()

source§

fn display(&self) -> Option<String>

👎Deprecated since 4.0.0: This crate now directly uses the fmt::Display impl on the error.

Implementors§