system
February 25, 2016, 6:07pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
Tybobobo
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:
[Config]
hostname="My awesome Server!"
maxclients=32
However, if someone edit the file and somehow screw up like this:
[Config]
hostname="My awesome Server!"
somevar=stringwithoutquotationmarks
maxclients=32
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
Posted this as an issue as well, by recommendation of Calinou ~
opened 06:31PM - 25 Feb 16 UTC
closed 09:14AM - 26 May 20 UTC
feature proposal
archived
topic:core
usability
**Issue description** (what happened, and what was expected):
Referring to this … question: http://godotengine.org/qa/331/how-would-i-handle-errors-when-loading-using-configfile
Calinou mentioned I could post it as an issue. I hope we can implement something that allows us to "continue" looking for keys and values even after an error has occurred to prevent complete shutdown when looking for keys and values underneath a bad line. :)
Since they are posted on separate lines; perhaps it will be possible to add exception handling for each line, but allow it to continue search for key&value even when an error has occurred.
system
February 25, 2016, 8:19pm
4
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:
File.open_encrypted()
Take a look at the File class’ documentation