godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Throw exception in GDNative cause game stop without message

Open nongvantinh opened this issue 4 years ago • 4 comments

With a simple throw std::exception the game stop without printing the message from the exception.

nongvantinh avatar Aug 22 '21 08:08 nongvantinh

Godot is not compiled with exceptions enabled, so I think this is expected behavior. Use the error macros at your disposal instead, such as ERR_FAIL_*(). You can return values of the Error enum to use as error codes.

Calinou avatar Aug 22 '21 08:08 Calinou

So I can't make the program stop. Print an error message is all I can do.

nongvantinh avatar Aug 22 '21 08:08 nongvantinh

Just use get_tree()->quit(1); after ERR_ macro

ghost avatar Aug 27 '21 18:08 ghost

There's also the CRASH_NOW() macro you can use.

Calinou avatar Aug 27 '21 19:08 Calinou