Skip to content
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

Customize panic handling #411

Open
Bromeon opened this issue Sep 14, 2023 · 1 comment
Open

Customize panic handling #411

Bromeon opened this issue Sep 14, 2023 · 1 comment
Labels
c: core Core components feature Adds functionality to the library

Comments

@Bromeon
Copy link
Member

Bromeon commented Sep 14, 2023

When a panic in gdext or Rust code happens, it is currently caught and displayed as a Godot error and on the command line.

Users may want to customize this. Behaviors could be:

  • Godot/console message of varying verbosity levels (message -> context -> stacktrace)
  • Instantly crash (to trigger a breakpoint)
  • Trigger a breakpoint without crashing (only possible with nightly breakpoint or platform specific crates/code)
  • Custom handler (would need to ensure thread safety)
@Bromeon Bromeon added feature Adds functionality to the library c: core Core components labels Sep 14, 2023
@Bromeon
Copy link
Member Author

Bromeon commented Mar 28, 2024

A lot of the panicking operations now have a fallible overload, see #634.

It can still make sense to customize the behavior when actual panics happen. One idea:

unsafe impl ExtensionLibrary for MyLibrary {
    fn panic_behavior() -> PanicBehavior { ... }
}

enum PanicBehavior {
    Default, // print to stdout + Godot
    CrashEngine,
    Breakpoint, // nightly-only
    Custom {
        callback: Box<dyn FnMut(...)>, // parameter could be message or panic object
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components feature Adds functionality to the library
Projects
None yet
Development

No branches or pull requests

1 participant