Skip to content

Add CallError, try_* varcalls and improve error diagnostics #634

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

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Feb 29, 2024

Overhauls the entire call diagnostic system, changing panics to Results internally and significantly improving user-facing error messages.

Fallible varcall methods such as Object::call() or Node::call_group() now receive an additional try_* overload which returns Result<T, CallError> instead of panicking. CallError is a new type that embodies function call errors, and allows to inspect the affected class/method, as well as the chain of calls.

Incidentally improves ConvertError messages, makes Variant's Debug impl more concise, and disables excessive panic printing in integration tests.

There is some work left for later PRs:

  • Utility functions (those should not get try_ overloads, but at least use the same code path).
  • Variant::call()
  • Callable::call().
  • Don't print error on try_* invocations.
  • More robust passing of CallError across Godot function boundaries (maybe 1 per thread instead of ever-growing).

Previously rendered as Variant(ty=..., val=...).
Now dispatches on the value and uses its `Debug` impl instead.

This should still be unambiguous, e.g. StringName/NodePath have &"..." and ^"..." syntax to differentiate them from GString.
@Bromeon Bromeon added feature Adds functionality to the library c: core Core components c: engine Godot classes (nodes, resources, ...) labels Feb 29, 2024
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-634

@Bromeon Bromeon added this pull request to the merge queue Feb 29, 2024
Merged via the queue into master with commit a00bf88 Feb 29, 2024
@Bromeon Bromeon deleted the feature/call-error branch February 29, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components c: engine Godot classes (nodes, resources, ...) feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants