summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_vm.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-10-16 18:43:11 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-10-16 18:43:11 +0200
commit50212ecfdbd80bdcbb94cc1ad50cd6e7e1c57562 (patch)
treebd04693d3ece3c5e3f850b33b2e3c8de1c8d1f0a /modules/gdscript/gdscript_vm.cpp
parenta60fc7f7c86daad48a8b23c9e4e1fe49cf3a0881 (diff)
parent0c2202c56e4c87c53dde17b35c8677974985ae81 (diff)
downloadredot-engine-50212ecfdbd80bdcbb94cc1ad50cd6e7e1c57562.tar.gz
Merge pull request #78882 from dalexeev/gds-fix-utility-func-err-msg
GDScript: Fix incorrect error message for utility functions
Diffstat (limited to 'modules/gdscript/gdscript_vm.cpp')
-rw-r--r--modules/gdscript/gdscript_vm.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 75dc2e4f8b..b723ecc185 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -2067,11 +2067,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (err.error != Callable::CallError::CALL_OK) {
String methodstr = function;
- if (dst->get_type() == Variant::STRING) {
+ if (dst->get_type() == Variant::STRING && !dst->operator String().is_empty()) {
// Call provided error string.
- err_text = "Error calling utility function '" + methodstr + "': " + String(*dst);
+ err_text = vformat(R"*(Error calling utility function "%s()": %s)*", methodstr, *dst);
} else {
- err_text = _get_call_error(err, "utility function '" + methodstr + "'", (const Variant **)argptrs);
+ err_text = _get_call_error(err, vformat(R"*(utility function "%s()")*", methodstr), (const Variant **)argptrs);
}
OPCODE_BREAK;
}
@@ -2123,13 +2123,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (err.error != Callable::CallError::CALL_OK) {
- // TODO: Add this information in debug.
- String methodstr = "<unknown function>";
- if (dst->get_type() == Variant::STRING) {
+ String methodstr = gds_utilities_names[_code_ptr[ip + 2]];
+ if (dst->get_type() == Variant::STRING && !dst->operator String().is_empty()) {
// Call provided error string.
- err_text = "Error calling GDScript utility function '" + methodstr + "': " + String(*dst);
+ err_text = vformat(R"*(Error calling GDScript utility function "%s()": %s)*", methodstr, *dst);
} else {
- err_text = _get_call_error(err, "GDScript utility function '" + methodstr + "'", (const Variant **)argptrs);
+ err_text = _get_call_error(err, vformat(R"*(GDScript utility function "%s()")*", methodstr), (const Variant **)argptrs);
}
OPCODE_BREAK;
}