Dimensional Doors Legacy

Dimensional Doors Legacy

7.4k Downloads

JsonSyntaxException is not an IOException

HenryLoenwind opened this issue ยท 2 comments

commented

https://github.com/DimensionalDevelopment/DimDoors/blob/1.12-WIP/src/main/java/org/dimdev/dimdoors/shared/pockets/SchematicHandler.java#L95

com.google.gson.JsonSyntaxException (extends JsonParseException extends RuntimeException) is not an IOException, so that catch is quite useless for parser exceptions and the resulting crash is missing any kind of hint what is happening.

commented

CompressedStreamTools.readCompressed throws an IOException if I recall correctly. It should be thrown when the file doesn't exist

commented

Yes, that catch itself is useful for when the file doesn't exist or cannot be opened. But if there's an error inside the file you will get a JsonParseException. Letting that one bubble up to top level will not give you any context information like file.getName(). So you'll have absolutely no idea where the error happened.

Note quite as useless as a catch (Throwable t) { println("There was an error"); exit(0); } but not far removed. ;)