mit_commit_message_lints/console/error_handling.rs
1//! Setup miette's pretty stack trace handling
2
3use std::env;
4
5use miette::GraphicalTheme;
6
7/// Setup miette's pretty stack trace handling
8///
9/// We also have a secret env `DEBUG_PRETTY_ERRORS` that disables all fancy
10/// output for the specdwon tests
11/// # Panics
12/// If we fail to install the panic hook
13pub fn miette_install() {
14 miette::set_panic_hook();
15 if env::var("DEBUG_PRETTY_ERRORS").is_ok() {
16 miette::set_hook(Box::new(|_| {
17 Box::new(
18 miette::MietteHandlerOpts::new()
19 .force_graphical(true)
20 .terminal_links(false)
21 .graphical_theme(GraphicalTheme::unicode_nocolor())
22 .build(),
23 )
24 }))
25 .expect("failed to install debug print handler");
26 }
27}