diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-22 13:02:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 13:02:48 +0100 |
commit | 8c5d4770e901b14750a972f4e2d3ac1e124ebff7 (patch) | |
tree | 83e68cd4065ec0296d5b396f7de2b7c06a4ce2f1 | |
parent | 114beb1bee5c93208f4cbc115ae2f7cc8b4346ac (diff) | |
parent | e6abdc943dfa33664d94c0b3cb27465039ea7819 (diff) |
Merge pull request #46243 from Calinou/improve-get-node-error-message
Improve the `get_node()` error message to be more descriptive
-rw-r--r-- | scene/main/node.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index f0c562260f..893621fbc4 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1442,7 +1442,15 @@ 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, nullptr, "Node not found: " + p_path + "."); + + if (p_path.is_absolute()) { + ERR_FAIL_COND_V_MSG(!node, nullptr, + vformat(R"(Node not found: "%s" (absolute path attempted from "%s").)", p_path, get_path())); + } else { + ERR_FAIL_COND_V_MSG(!node, nullptr, + vformat(R"(Node not found: "%s" (relative to "%s").)", p_path, get_path())); + } + return node; } |