How would I handle errors when loading using ConfigFile?

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

If I for example load this file and attempts to get both values, I succeed without a problem:

hostname="My awesome Server!" 

However, if someone edit the file and somehow screw up like this:

hostname="My awesome Server!" 

It wont be able to get any data after somevar, even when using value and key.

How can I “skip” the errors, ignoring them, so that I may get out other values below the “error”?

All help is much appreciated :slight_smile:

Posted this as an issue as well, by recommendation of Calinou ~

:bust_in_silhouette: Reply From: brunosxs

It wouldn’t…
The only way I see some kind of recovering system would be to parse and interprete the config file… But if you bothered to create a parser then I don’t see a reason to use the ConfigFile class…

You could encrypt the file so the user would not be able to change and as such would practically eliminate the chance of creating corrupted files by the user part. For this look at the File Class, especifically at this method:


Take a look at the File class’ documentation