TheElectronWill / night-config

Powerful java configuration library for toml, yaml, hocon, json and in-memory configurations. Serialization/deserialization framework.
GNU Lesser General Public License v3.0
242 stars 28 forks source link

Please improve exceptions thrown by the parser #165

Open burdoto opened 8 months ago

burdoto commented 8 months ago
Caused by: com.electronwill.nightconfig.core.io.ParsingException: Invalid bare key: ]
         at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:175) ~[toml-3.6.4.jar%2393!/:?]
         at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.4.jar%2393!/:?]
         at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.4.jar%2393!/:?]
         at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.4.jar%2393!/:?]
         at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.4.jar%2393!/:?]
         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.4.jar%2392!/:?]
         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.4.jar%2392!/:?]
         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.4.jar%2392!/:?]
         at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.4.jar%2392!/:?]
         at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.4.jar%2392!/:?]
         at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:43) ~[fmlcore-1.20.1-47.2.20.jar%23458!/:?]
         ... 10 more

Yes I know this is inside Minecraft Forge. The issue lies within the parser; a parser exception couldn't be less explanative than this.

Figuring out where exactly this issue came from had cost me an entire hour. For a parser exception. Please address this; this is just frustrating as hell.

burdoto commented 8 months ago

please note that i am well aware that this says "caused by" because this exception is wrapped in another one. i reported this after finding this issue when SUDDENLY forge decided to rethrow the exception. my point still stands. a parser exception should not be like this.

TheElectronWill commented 8 months ago

I understand the frustration, it could certainly be better, yes. I think there's already an issue for that (#105).

However, please understand that my time is unfortunately limited, like everyone else. Tracking precise line and column numbers isn't completely trivial.

burdoto commented 8 months ago

I totally understand and didn't mean to push you into fixing it immediately. As noted, I think that Forge is the one to actually blame most here (how surprising /s), because its only in certain scenarios wrapping the parser exception with a more detailed exception that contains at least information about the source mod.