By bloid
via littletutorials.com
Published: Apr 28 2008 / 07:22
Dealing with exceptions is hard. For a while now in the Java world there are two camps. One considers the initial design of the Java exceptions system a sensible one, a feature that contributed greatly to Java’s success. A new camp has also formed in Java world and this new camp considers the original design fundamentally flawed and in dire need of rework.
Comments
sproketboy replied ago:
This is the comment I left on that blog.
I’ve thought recently that there should be a new JSR to move the general checked exceptions in Java to runtime exceptions. This is is because checked exceptions really should be Domain exceptions (InsufficientFundsException, CustomerNotFoundException, NoInventoryInStockException etc).
SQLException, IOException etc are really almost always runtime exceptions anyway and are the main pain-point IMO for checked exceptions in Java. These tend to need to be caught/tranlated/rethrown over and over again. And tend to pollute our domain objects.
Nikita Ivanov replied ago:
It has always been beyond me how one can think that SQLException or IOException can be a runtime exception- essentially, not needed to be caught or handled, usually representing non-recoverable errors. Where one to begin think in this way?? How can anyone equate NPE with SQLException or IOException???
sproketboy replied ago:
Right. Checked exceptions are for recoverable errors. You answered your own question.
Voters For This Link (12)
Voters Against This Link (1)