Ignored error doesn't let me log it properly
Opened this issue · 1 comments
I'm a noob with log4j so if there is a way... well.
The archive constructors call readheaders eventually. There there is a log of alll exceptions:
WARNING: exception in archive constructor maybe file is encrypted or currupt
and a comment on that catch:
//ignore exceptions to allow exraction of working files in
//corrupt archive
In my data, there is one or two files that are corrupt/encrypted: that catch logs a NullPointerException (i didn't pass null). However, as it is a nullpointer, not a IOException, i don't have a file name (or indeed, i don't have anything to report to the user, because that the exception triggered is opaque to the code).
I'd prefer if this corner case was configurable, maybe by throwing a exception at the end of the constructor, documenting on it that you can still try using the archive for the non-corrupted parts, or a 'getError' or a similar scheme.
The reason it is throwing NullPointerException is that UnrarHeadertype.findType is returning null for the byte marker it is sent. I'm handling this by installing a handler for the specific logger of the Archive class which wraps given throwables in a runtimeexception and throws them again, then they're caught on my libraray boundary and wrapped on a domain specific exception.