Topic was automatically imported from the old Question2Answer platform.
Asked By
Rodrigo Matos
I don’t understand how to work with errors in Godot. I know it’s Godot’s design choice to not provide exception functionality, so should I just accept getting errors as something ok?
For example, i’m using this method: host.create_server(DEFAULT_PORT, MAX_PEERS) to create a server. But what if I get a ERR_CANT_CREATE error? In my code, I put the error in a var and I run a condition to treat it, but is this the right way? It looks workaround-esque. My program flow doesn’t suffer from that, but is there any performance problem?
In my code, I put the error in a var and I run a condition to treat it, but is this the right way?
Yes, this is how you should do it in GDScript
My program flow doesn’t suffer from that, but is there any performance problem?
There’s no performance issue associated with the lack of exceptions. If anything, it’s the opposite: exceptions are known to add runtime overhead to programs (especially in performance-critical languages like C++). For the record, Godot’s C++ code doesn’t rely on exceptions at all.