The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+7 votes

Somewhat related to my last question.
Is there a way, kinda like try and catch in most programming languages, to get the error message in case of crash instead of making the debugger stopping the game?

As an exemple an user wants to run 2+a but the debugger yields on with the error: "Parser Error: Identifier not found: a". I would like to be able to get the error as a string (not using printerr or so to print it to command line, I want it to be able to show in-game) and to let the game continue its normal execution.

in Engine by (24 points)

2 Answers

0 votes

According to this issue, there's apparently no way to catch exceptions with Godot. And that won't change anytime soon. :/

by (28 points)
+5 votes

I know this is an old question, putting this here for future viewers

I can detect an error in the core engine (eg trying to call a function on a freed node) with the following code:

func _notification(what):
    if what == MainLoop.NOTIFICATION_CRASH:
        pass # the game crashed

Works on Godot 3.1.1
You won't get the error description, but you can tell the player that something happened in a released game

by (157 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.