[feat] Capture and display all errors, even if Tauri cannot resolve them
Describe the problem
I have encountered multiple instances of applications crashing inexplicably. After such an issue occurred, no relevant information was found in the. log file, and only the relevant Application Error (exception code 0xc0000005) could be seen in the Windows Event Viewer. There was no useful information other than that, such as #11356 . This greatly hinders the reproduction and investigation of the problem.
Describe the solution you'd like
Rust does a good job in error handling and passing. Is it possible to capture all possible errors and prompt them through MessageBox or similar obvious ways?
Alternatives considered
No response
Additional context
No response
To me, I did something like this in my app, and the crash would be shown in the log file tauri_plugin_log created
let default_panic = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
let backtrace = Backtrace::force_capture();
log::error!("Panic: {info}\n{backtrace}");
default_panic(info);
}));
To me, I did something like this in my app, and the crash would be shown in the log file
tauri_plugin_logcreated对我来说,我在我的应用程序中做了类似的事情,并且崩溃将显示在创建的日志文件中let default_panic = std::panic::take_hook(); std::panic::set_hook(Box::new(move |info| { let backtrace = Backtrace::force_capture(); log::error!("Panic: {info}\n{backtrace}"); default_panic(info); }));
@Legend-Master Thank you. Is this code placed in the following location?
tauri::Builder::default().setup(|app| {
let default_panic = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
let backtrace = Backtrace::force_capture();
log::error! ("Panic: {info}\n{backtrace}");
default_panic(info);
}));
...
I'll just put it at the beginning of the main function, but this is fine as well