-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript: Add error message when a GDScript resource fails to load. #78540
Conversation
modules/gdscript/gdscript.cpp
Outdated
@@ -2698,6 +2698,10 @@ 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) { | |||
ERR_PRINT(vformat(R"(Failed to load script at path "%s". Error code %d.)", p_path, err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check whether ERR_PRINT_ED
also writes an error to the console, or even whether, when autoloads get loaded, these errors would be visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is possible to distinguish what period the error is, see #76954 (comment):
ERR_PRINT(vformat(R"(Failed to load script at path "%s". Error code %d.)", p_path, err)); | |
if (scr.is_valid()){ | |
// Errors during compilation. | |
}else{ | |
// Errors during loading. | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion, @Rindbee
Added the |
Recently encountered this, and wanted to open a PR to fix but found this. @anvilfolk are you still working on this? Looks like it's ready, just needs the suggested patch applied? Happy to help test or contribute if any help is needed here |
Sorry, life's been a bit of a mess. I'm hoping to have a little more time in the coming weeks and want to work on this again, yes :) @Rindbee so if |
This usually means an error occurred in godot/modules/gdscript/gdscript_cache.cpp Lines 257 to 261 in 3fa8fad
Other than that, it's a valid script. This is for the first load, subsequent loads are a bit different. godot/modules/gdscript/gdscript_cache.cpp Lines 296 to 299 in 3fa8fad
|
36ca717
to
5a5bccb
Compare
A couple of notes:
I don't think we can get around the "duplicated" errors, since |
4f41d95
to
a9b3b09
Compare
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 godotengine#78230.
Thanks! |
Cherry-picked for 4.1.2. |
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 when errors occur in projects when autoloads are involved. At least partially closes #78230.