The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Exception-Handling Antipatterns
Subject:  Don't throw RuntimeException either
Date:  2007-06-12 01:37:18
From:  agnus
Response to: Don't throw RuntimeException either


Besides not throwing Exception, you should also never throw RuntimeException, Error, or even worse, Throwable.


I beg to disagree. Suppose a program that is created and executed in a perfect environment, where there won't be any errors either from the code itself, the hardware or the operator. Such a program should not need a single try / catch / throw statement within it's sources.

However the world we live in is imperfect and at any given moment / situation there are infinite problems that can arise. Therefore if we wanted to make this program as secure as possible we could declare near infinite exception throws at any given method! Ofcource that would be madness and that is why checked-exceptions are evil.

Exceptions should reflect exactly that.. exceptional situations and I should be able to ignore any of them - either because I am in perfect knowledge, or because I am ignorant, or because I am plain lazy -.

 Feed java.net RSS Feeds