night-config icon indicating copy to clipboard operation
night-config copied to clipboard

Please improve exceptions thrown by the parser

Open burdoto opened this issue 10 months ago • 3 comments

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.

  • I dont know what file this is from (ok i blame forge for this)
  • I dont know what line this is from
  • Let alone the column of the input
  • I ONLY know there is a bad ] somewhere

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 avatar Mar 27 '24 21:03 burdoto

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.

burdoto avatar Mar 27 '24 21:03 burdoto

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.

TheElectronWill avatar Mar 27 '24 22:03 TheElectronWill

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.

burdoto avatar Mar 28 '24 18:03 burdoto