JsonSyntaxException is not an IOException
HenryLoenwind opened this issue ยท 2 comments
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.
CompressedStreamTools.readCompressed
throws an IOException
if I recall correctly. It should be thrown when the file doesn't exist
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. ;)