diff options
| author | ocean (they/them) <anvilfolk@gmail.com> | 2023-06-21 14:19:52 -0400 |
|---|---|---|
| committer | ocean (they/them) <anvilfolk@gmail.com> | 2023-07-31 13:16:29 -0400 |
| commit | cca57171c16c90d6acec4e0eef1ed904973bcb20 (patch) | |
| tree | f8e4f1ab251361b9076bdb7f43ab46ebef5882e7 /modules | |
| parent | 3fa8fad26b97a8af20e7996b7e17d8f23fc04b89 (diff) | |
| download | redot-engine-cca57171c16c90d6acec4e0eef1ed904973bcb20.tar.gz | |
Add error message when a GDScript resource fails to load.
Currently, GDScripts who are only loaded through `ResourceLoader::load()`,
like Autoloads, do not have a pathway to announce there is an error in their
code. This contributes to significant confusion in error projects when
autoloads are involved. At least partially closes #78230.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/gdscript/gdscript.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 0bf9f72a2c..42b08f8a68 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2695,6 +2695,11 @@ Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const Str Error err; Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE); + if (err && scr.is_valid()) { + // If !scr.is_valid(), the error was likely from scr->load_source_code(), which already generates an error. + ERR_PRINT_ED(vformat(R"(Failed to load script "%s" with error "%s".)", p_path, error_names[err])); + } + if (r_error) { // Don't fail loading because of parsing error. *r_error = scr.is_valid() ? OK : err; |
