[std] In Win32 mode, display an error dialog on `panic!()`

In Win32 mode, with the default panic hook set, panicking occurs without explicit notification, and getting panic information becomes hard.

By adding an error dialog on panic in the default panic hook in Win32 mode, when panic!() occurs, we can access panic information more easily, which helps debugging and user experience. For example, the panic dialog could contain a button to save panic information to a specified file, so the user can report errors more easily.

By adding the dialog in the panic hook than somewhere else, use cases not expecting a panic dialog are possible, since resume_unwind does not call the panic hook, and the panic hook can be user-replaced.

You can write a crate which implements this functionality. It definitely sounds useful for many GUI applications. Though many might prefer that functionality being integrated in the GUI framework they use, instead of using a standalone crate.

If it proves popular, integrating the functionality by default could be discussed at a later point.

Looks like there are crates for that already, for example panicui.

2 Likes