NetworkedMultiplayerENet and the error issue

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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?

:bust_in_silhouette: Reply From: Calinou

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 :slight_smile:

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.

Thanks, this is different from what I’m used to.

Rodrigo Matos | 2020-03-26 12:43