1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Merge pull request #46243 from Calinou/improve-get-node-error-message

Improve the `get_node()` error message to be more descriptive
This commit is contained in:
Rémi Verschelde
2021-02-22 13:02:48 +01:00
committed by GitHub

View File

@@ -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(const NodePath &p_path) const {
Node *node = get_node_or_null(p_path); 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; return node;
} }