From b3922a42e9f718c1a1ecd753c461657f9b158225 Mon Sep 17 00:00:00 2001 From: ShimmyShaman Date: Fri, 22 Apr 2022 16:10:48 +1200 Subject: [PATCH] improved error msg for gdscript load_source_code --- modules/gdscript/gdscript.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 59254fc3ad2..55c7ace9384 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1032,7 +1032,13 @@ Error GDScript::load_source_code(const String &p_path) { Error err; Ref f = FileAccess::open(p_path, FileAccess::READ, &err); if (err) { - ERR_FAIL_COND_V(err, err); + const char *err_name; + if (err < 0 || err >= ERR_MAX) { + err_name = "(invalid error code)"; + } else { + err_name = error_names[err]; + } + ERR_FAIL_COND_V_MSG(err, err, "Attempt to open script '" + p_path + "' resulted in error '" + err_name + "'."); } uint64_t len = f->get_length();