1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::process::{ExitCode, Termination};
use error_stack::{Context, Report};
#[derive(Debug)]
struct CustomError;
impl Context for CustomError {}
impl std::fmt::Display for CustomError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Custom Error")
}
}
fn main() -> ExitCode {
let report = Report::new(CustomError)
.attach(ExitCode::from(100))
.attach_printable("this error has an exit code of 100!");
report.report()
}