Trait zellij_utils::errors::FatalError

source ·
pub trait FatalError<T> {
    // Required methods
    fn non_fatal(self);
    fn fatal(self) -> T;
}
Expand description

Special trait to mark fatal/non-fatal errors.

This works in tandem with LoggableError above and is meant to make reading code easier with regard to whether an error is fatal or not (i.e. can be ignored, or at least doesn’t make the application crash).

This essentially degrades any std::result::Result<(), _> to a simple ().

Required Methods§

source

fn non_fatal(self)

Mark results as being non-fatal.

If the result is an Err variant, this will print the error to the log. Discards the result type afterwards.

source

fn fatal(self) -> T

Mark results as being fatal.

If the result is an Err variant, this will unwrap the error and panic the application. If the result is an Ok variant, the inner value is unwrapped and returned instead.

§Panics

If the given result is an Err variant.

Implementors§

source§

impl<T> FatalError<T> for Result<T>