Skip to content

Commit

Permalink
Merge pull request #78540 from anvilfolk/gdresloaderr
Browse files Browse the repository at this point in the history
GDScript: Add error message when a GDScript resource fails to load.
  • Loading branch information
akien-mga committed Aug 3, 2023
2 parents 4ed0840 + cca5717 commit 5e1671a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/gdscript/gdscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5e1671a

Please sign in to comment.