#How to get the enum code from the @GlobalScope.Error
1 messages · Page 1 of 1 (latest)
enums are technically just integers, so if you print the return value, you will see the number. and if you use error_string(<that number>) you will get the message
Thanks so much fro the help. First I should mention that I'm using 3.5 (I only put that in the tag, sorry). It doesn't look like error_string is a method. But I'm unable to get the number in my own code the first place. I think I might be a little confused actually with how load() works in terms of errors. The code below is a simplification of what I'm trying to do.
imported_scene = load(file)
if imported_scene:
# Do something
else:
emit_signal("display_message", "Error: " + imported_scene as String)
If there's an issue with the file I'm trying to load, the console gives me an error from the Enums. But the return value from load() is actually null, not an error enum, which is why trying to render it as a string gives another error. Following the first error to the engine code (https://github.com/godotengine/godot/blob/6c814135b69d4e703956bacc2073b4b179ff5a00/core/io/resource_loader.cpp#L206) shows me that the error is being generated from the ResourceFormatLoader in this case, but I don't know how to access that class in my code. I'm not sure if there is a GlobalScope error stored somewhere that I can draw from or not. Hopefully this makes sense
ah load will return the loaded resource. or nothing if there was an error. the global load is basically a shortcut to this one
https://docs.godotengine.org/en/3.5/classes/class_resourceloader.html#class-resourceloader-method-load
not sure which error you want out of this though. you can check if the resource exists() though
So in this case, this is loading addons/mods for the app, the addon I created had a cyclical dependency which triggered a parse error. So I was hoping to be able to give any future addon devs a more useful error message than just "error" in case they made the same mistake as me since they won't have access to the console on the main app. Maybe it's overkill, but it would be nice to be able to figure out
yeah not really possible. we couldn't do it either with the mod loader. that's just stuff that needs to be nailed down by them while in development mode. and the application logs will also contain those messages
Oh that's good to know, thank so much for your help
What are you working on that also has mods? I'm curious
(if you don't mind sharing)
the mod loader itself 😅
haha nice
we put it in dome keeper, brotato and windowkill with the devs
Very cool !
ref https://github.com/GodotModding/godot-mod-loader/ if you want to take some inspiration from it
Ah awesome thank you, I wish I had found this earlier before I got deep into making my own 😅 I'll definitely take a look to see if I can get idea for improvements on my code
feel free to @ me for related questions 😉