1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Setup miette's pretty stack trace handling

use std::env;

use miette::GraphicalTheme;

/// Setup miette's pretty stack trace handling
///
/// We also have a secret env `DEBUG_PRETTY_ERRORS` that disables all fancy
/// output for the specdwon tests
/// # Panics
/// If we fail to install the panic hook
pub fn miette_install() {
    miette::set_panic_hook();
    if env::var("DEBUG_PRETTY_ERRORS").is_ok() {
        miette::set_hook(Box::new(|_| {
            Box::new(
                miette::MietteHandlerOpts::new()
                    .force_graphical(true)
                    .terminal_links(false)
                    .graphical_theme(GraphicalTheme::unicode_nocolor())
                    .build(),
            )
        }))
        .expect("failed to install debug print handler");
    }
}