The color_eyre crate provides error report handlers for panics and errors. It displays the
reports formatted and in color. To use these handlers, a Ratatui app needs to restore the terminal
before displaying the errors.
In your terminal initialization function, add some new code that replaces rusts default panic
handler with one that restores the terminal before displaying the panic details. This will be used
by both panics and unhandled errors that fall through to the end of the program.
Usage
In your application, wrap errors with extra context as needed:
Add the following import:
Call wrap_err from methods that can fail with an error.
Demo
Full code
Panic
With RUST_BACKTRACE=full:
Error
With RUST_BACKTRACE=full:
Normal exit
Further Steps
See the color_eyredocs and examples for more advanced setups. E.g.: