From 2735a5498e01cbeb882b5adbc0e9fcfcd847df8f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 20 Feb 2021 02:05:19 +0100 Subject: [PATCH] Improve the `get_node()` error message to be more descriptive - Mention the origin of the `get_node()` call. - Mention whether the attempted path is absolute or relative. See #46214. (cherry picked from commit e6abdc943dfa33664d94c0b3cb27465039ea7819) --- scene/main/node.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b0efe893b98..9ff6c45aeff 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1378,7 +1378,14 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); - ERR_FAIL_COND_V_MSG(!node, NULL, "Node not found: " + p_path + "."); + if (p_path.is_absolute()) { + ERR_FAIL_COND_V_MSG(!node, NULL, + vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path())); + } else { + ERR_FAIL_COND_V_MSG(!node, NULL, + vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path())); + } + return node; }