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

Improve Timer error messages #95572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 15, 2024

  • Mention the node path (or node name if not in tree).
  • Mention the provided invalid wait time.

Testing project: test_timer_error_messages.zip

Preview

Before

ERROR: Timer was not added to the SceneTree. Either add it or set autostart to true.
   at: start (scene/main/timer.cpp:109)

ERROR: Time should be greater than zero.
   at: set_wait_time (scene/main/timer.cpp:83)

After

ERROR: Timer (out-of-tree): Timer was not added to the SceneTree. Either add it to the SceneTree using `add_child()`, or set the `autostart` property to `true`.
   at: start (./scene/main/timer.cpp:109)

ERROR: Timer2 (out-of-tree): The wait time should be greater than 0 seconds, but a wait time of -0.500000 was provided.
   at: set_wait_time (./scene/main/timer.cpp:83)

- Mention the node path (or node name if not in tree).
- Mention the provided invalid wait time.
@Calinou Calinou added this to the 4.4 milestone Aug 15, 2024
@Calinou Calinou requested a review from a team as a code owner August 15, 2024 17:07
@@ -80,7 +80,7 @@ void Timer::_notification(int p_what) {
}

void Timer::set_wait_time(double p_time) {
ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero.");
ERR_FAIL_COND_MSG(p_time <= 0, vformat("%s: The wait time should be greater than 0 seconds, but a wait time of %f was provided.", is_inside_tree() ? String(get_path()) : String(get_name()) + " (out-of-tree)", p_time));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this would benefit from Node.get_debug_path(), which I added in #95579. This way, we can reduce code repetition significantly, as a lot of messages will eventually benefit from printing out node paths (and falling back to the node name if out-of-tree).

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

Successfully merging this pull request may close these issues.

1 participant