Godot does not really have an error handling system. ## Errors Enum Godot has an `Enum` (kinda) called `Error`. Godot's internal functions may return any of these errors. It is not possible to extend this list of errors without modifying the engine. This enum is implemented in [[C++]] and is not fully integrated with [[GDScript]]. None of the standard functions which can be used with [[GDScript]] enums can be used with these `@GlobalScope` ## Convert Error to String ```python errorstring(error) ``` --- It is ~~possible~~ to write a variety of shim methods to safely check for each individual named enum: ```python func error_to_string(error : Error) -> String: return ClassDB.class_get_integer_constant_list("@GlobalScope")[error] func midi_to_string(midi : MIDIMessage) -> String: return ClassDB.class_get_integer_constant_list("@GlobalScope")[midi] # repeat ad nauseam ``` One possible approach would be removing the type limitation. But means that arbitrary integers or non-GlobalScope enums could be misinterpreted by the method and even cause runtime errors! ```python func globalscope_enum_to_string(gs_enum : int) -> String: return ClassDB.class_get_integer_constant_list("@GlobalScope")[gs_enum] func _ready(): var some_var : int = 48 print(globalscope_enum_to_string(some_var)) # "Out of bound get index" error! The type checker has failed me! ``` Enums are not "real" types at runtime, they are just a thin layer over `int`. Which means there is no entry in `Variant` and I cannot called `get_class` on them. So the only way to do type checking is at compile/parse time via the named enum pseudo-dictionary, when provided. This is fine, but it means that there is no safe way to cover all enums in GlobalScope without copy and pasting a lot of code. If the [type union](https://github.com/godotengine/godot-proposals/issues/737) proposal is implemented, then I could add every possible global named enum to the function signature of a single method, which would be a mild improvement.