Is there a way to catch an exception in GdScript instead of running the debugger?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GovanifY
:warning: Old Version Published before Godot 3 was released.

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.

:bust_in_silhouette: Reply From: Lertsenem

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

:bust_in_silhouette: Reply From: droc101

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