Skip to content

[feat] Capture and display all errors, even if Tauri cannot resolve them #13482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Think-M opened this issue May 21, 2025 · 3 comments
Open

Comments

@Think-M
Copy link

Think-M commented May 21, 2025

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

@Legend-Master
Copy link
Contributor

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);
}));

@Think-M
Copy link
Author

Think-M commented May 22, 2025

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);
}));

@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);
    }));
    ...

@Legend-Master
Copy link
Contributor

I'll just put it at the beginning of the main function, but this is fine as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants