summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2024-02-08 13:49:44 +0100
committerGitHub <noreply@github.com>2024-02-08 13:49:44 +0100
commit41564aaf7708b0bf594f745dd2448a54dd687cc5 (patch)
treef37aaf7d98d3524b243d4501bc3656b2a213c6ee /modules
parentbe2eb09f4d333b64da296e8afcac97d582e080d5 (diff)
parentcae3b822c3ab135cceb902d6ab1d572fd9723861 (diff)
downloadredot-engine-41564aaf7708b0bf594f745dd2448a54dd687cc5.tar.gz
Merge pull request #86999 from AThousandShips/init_note
Improve error message when a GDScript instance fails to be constructed
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 0da7752940..e78c113c6c 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -162,13 +162,14 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
_super_implicit_constructor(this, instance, r_error);
if (r_error.error != Callable::CallError::CALL_OK) {
+ String error_text = Variant::get_call_error_text(instance->owner, "@implicit_new", nullptr, 0, r_error);
instance->script = Ref<GDScript>();
instance->owner->set_script_instance(nullptr);
{
MutexLock lock(GDScriptLanguage::singleton->mutex);
instances.erase(p_owner);
}
- ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance.");
+ ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance: " + error_text);
}
if (p_argcount < 0) {
@@ -179,13 +180,14 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
if (initializer != nullptr) {
initializer->call(instance, p_args, p_argcount, r_error);
if (r_error.error != Callable::CallError::CALL_OK) {
+ String error_text = Variant::get_call_error_text(instance->owner, "_init", p_args, p_argcount, r_error);
instance->script = Ref<GDScript>();
instance->owner->set_script_instance(nullptr);
{
MutexLock lock(GDScriptLanguage::singleton->mutex);
instances.erase(p_owner);
}
- ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance.");
+ ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance: " + error_text);
}
}
//@TODO make thread safe