From 7eacc457ee8b170bd7876c439ca130f970737f0c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 15 Aug 2024 19:01:37 +0200 Subject: [PATCH] Improve Timer error messages - Mention the node path (or node name if not in tree). - Mention the provided invalid wait time. --- scene/main/timer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 0f4f18b495e..9050a6943ce 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -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)); wait_time = p_time; update_configuration_warnings(); } @@ -106,7 +106,7 @@ bool Timer::has_autostart() const { } void Timer::start(double p_time) { - ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree. Either add it or set autostart to true."); + ERR_FAIL_COND_MSG(!is_inside_tree(), vformat("%s (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`.", get_name())); if (p_time > 0) { set_wait_time(p_time);