#panic #panic-hook #development-tools #visualpanic

nightly visualpanic-rs

A library providing a panic hook for Rust applications that visualizes the panic with a native error dialog on supported systems

3 releases

0.1.2 Nov 21, 2023
0.1.1 Nov 21, 2023
0.1.0 Nov 21, 2023

#703 in Debugging

MIT license

9KB
79 lines

VisualPanic (visualpanic-rs)

Crates.io License

A library providing a panic hook for Rust applications that visualizes the panic with a native error dialog on supported systems (see listed OSes at native-dialog).

Installation

cargo add visualpanic_rs

Example 1: Use the default settings and register for the whole application

use visualpanic_rs::VisualPanic;
fn main() {
     VisualPanic::default().register_global();
}

Example 2: Use custom settings and register for the whole application

use visualpanic_rs::VisualPanic;
use visualpanic_rs::VisualPanicLevel;
fn main() {
     VisualPanic::new(
         Some("path/to/custom_icon.png"),
         Some("Custom Title"),
         Some(VisualPanicLevel::Info))
     .register_global();
}

lib.rs:

VisualPanic

Visualize panics with native GUI dialogs on supported systems (see list at https://crates.io/crates/native-dialog).

Provides a solution to panic visually, useful for GUI applications where a console view might not be available at all times. Customizable in some ways, e.g., which icon, title and dialog level should be used.

Example 1: Use the default settings and register for the whole application

fn main() {
    VisualPanic::default().register_global();
}

Example 2: Use custom settings and register for the whole application

fn main() {
    VisualPanic::new(
        Some("path/to/custom_icon.png"),
        Some("Custom Title"),
        Some(VisualPanicLevel::Info))
    .register_global();
}

Dependencies

~0.6–10MB
~112K SLoC