#error-exit #exiting #process #graceful #error-message #error-context

eoe

This crate provides utilities for exiting processes on errors gracefully

8 releases

Uses new Rust 2024

0.3.3 Sep 1, 2025
0.3.2 Apr 14, 2025
0.3.1 Mar 21, 2025
0.2.0 Feb 28, 2025
0.1.1 Jul 14, 2024

#764 in Rust patterns

Download history 3/week @ 2025-08-16 5/week @ 2025-08-23 106/week @ 2025-08-30 17/week @ 2025-09-06 4/week @ 2025-09-13 6/week @ 2025-10-11 10/week @ 2025-10-18

461 downloads per month
Used in 2 crates

MIT license

14KB
148 lines

Exit on Error

Crates.io Documentation License

This crate provides utilities for exiting processes on errors gracefully, leveraging anyhow to display detailed error context and chained messages.

Examples

Exiting on error:

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();
Show output
error: Doo-boo-boom-ba-beh-beh
caused by: Doom-boom-ba-beh
caused by: Mm-noom-ba-deh

Or if you prefer the word quit:

use anyhow::{Context, anyhow};
use eoe::QuitOnError;

Err::<(), _>(anyhow!("Mm-ba-ba-beh, mm-ba-ba-beh"))
    .context("Dee-day-da, ee-day-da")
    .quit_on_error();
Show output
error: Dee-day-da, ee-day-da
caused by: Mm-ba-ba-beh, mm-ba-ba-beh

The output style is customizable:

use eoe::{ExitOnError, Segment, Style};

let _ = eoe::ERROR.set(Segment {
    style: Style::new().bold().blue(),
    value: "Watchin' some good friends screamin'",
});
let _ = eoe::SEP.set(Segment {
    style: Style::new(),
    value: " 😱 ",
});
let _ = eoe::MESSAGE_STYLE.set(Style::new().italic().yellow());
let _ = eoe::MESSAGE_ON_NONE.set("Let me out");

None::<()>.exit_on_error();
Show output
Watchin' some good friends screamin' 😱 Let me out

Dependencies

~0.3–2.1MB
~39K SLoC