ExitOnError

Trait ExitOnError 

Source
pub trait ExitOnError<T>: Sealed {
    // Required method
    fn exit_on_error(self) -> T;
}
Expand description

A trait for exiting processes gracefully.

Required Methods§

Source

fn exit_on_error(self) -> T

Exits the process with an error message if the result is an error or the option is None.

Implementations on Foreign Types§

Source§

impl<T> ExitOnError<T> for Option<T>

Source§

fn exit_on_error(self) -> T

Exits the process with an error message if the option is None.

§Examples
use eoe::ExitOnError;

None::<()>.exit_on_error();
Source§

impl<T, E> ExitOnError<T> for Result<T, E>
where E: Into<Error>,

Source§

fn exit_on_error(self) -> T

Exits the process with an error message if the result is an error.

§Examples
use anyhow::{Context, anyhow};
use eoe::ExitOnError;

Err::<(), _>(anyhow!("Mm-noom-ba-deh"))
    .context("Doom-boom-ba-beh")
    .context("Doo-boo-boom-ba-beh-beh")
    .exit_on_error();

Implementors§