0 votes

I'm checking whether a custom file is in the right format or not corrupted.
If not, the game should give a blocking error message and close on OK.
But I can't find in depth information about dealing with errors.

How I get the script and calling line of GDScript to add to the a print message?
How I pop up an error message dialog box? (I'm developing for desktop)
If the data is not right, I can see a lot of issues if I let it go but calling get_tree().quit(), execution continues until the game is actually closed. There is no way to force it?

in Engine by (23 points)
edited by

1 Answer

+1 vote
Best answer

Is horrible when a game closes with an ugly window and frozen background (or just quit) because an expected error occurred (like files corrupted).

You can autoload a scene that has ready some dialog and a nice background, and maybe error information and bug report instructions, to put over the current scene when error happens.

Your error handling scene could listen for events, signals or just have a method to add the error window and remove the calling scene from the tree (and maybe write an error log).

by (7,840 points)
selected by

So when an unexpected errors occurs (like a file that doesn't exists and I forget to handle a possible error for this case) in release mode no information what so ever, no mechanism to close or log it and the game will just continue using unexpected data?

are you requesting a way to be able to handle unhandling error no matter what it comes?

Most languages will exit or output some kind of error even in release mode when you try to reference something in a null variable (invalid memory reference). If you don't handle them these errors are handled automatic. I'm asking whetter there is a feature like this in this language.
Anyway if there isn't, its fine. I really like the suggestion above for expected ones and I hope I'll never forget to check null values.

Normally, when you don't expect an error (not even a try-catch) and something really bad happens, the application crashes.

And Godot may print something on the console, need to check.

Ok, is really hard to make the stupid engine to crash xD

Just was able to get a segfault trying to use a method on a null variable without debug enabled.

There are stuff that should not pass a playtesting, like null variables, bad node names or method typos, exporting with debug enabled will throw a message on the console when errors occur.

For errors like corrupted or edited save files, you will have to do the consistency checks (not a common practice) when saving and loading to prevent problems.

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 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 webmaster@godotengine.org with your username.