Overall, I agree. Declaring checked exceptions has two main problems: First, it does get awkward as they proliferate, and second, they constitute an abstraction leak, as they reveal implementation details. Wrapping exceptions addresses both these problems.
I deferred discussing these issues in order to keep the scope of the article in check. I'd like to do a follow up, and detail this issue there. But in the meantime, I'm uncomfortable wrapping with a RuntimeException, because it violates the "be specific rule". It also means that your catch blocks likely will either be generic (simply catching and displaying a RuntimeException) or filled with a bunch of "instanceof" operations on the cause. This can be awkward.
Also, is it necessary to log "database error" or "wrong file name"? When the re-thrown RuntimeException is caught, that information will can be logged then. See my personal article, Exception Horror Stories for comments on the dangers of double-logging. |