|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Throwable | +--java.lang.Error | +--org.thdl.util.ThdlLazyException
A ThdlLazyException wraps a "real" java.lang.Exception. ThdlLazyException, however, is unchecked. Thus, if you want to be a lazy Java programmer, you can use this idiom:
// Note that bleh does not throw any checked exceptions: public static void bleh() { try { Foo.bar(); } catch (Throwable t) { // Nah, this'll never happen! throw new ThdlLazyException(e); } }
Now your code appears to be well written, and no one but the user will ever know the difference.
In Java 1.4 (1.3?), Sun introduced constructors for java.lang.Error that allow much the same thing. This code is Java 1 compatible, though, and is also a red flag, equivalent to a // FIXME comment.
Field Summary | |
private Throwable |
wrappedException
the wrapped exception |
Fields inherited from class java.lang.Error |
|
Fields inherited from class java.lang.Throwable |
|
Constructor Summary | |
ThdlLazyException()
Constructor for ThdlLazyException. |
|
ThdlLazyException(String descrip)
Constructor for ThdlLazyException. |
|
ThdlLazyException(String descrip,
Throwable realException)
Constructor for ThdlLazyException. |
|
ThdlLazyException(Throwable realException)
Constructor for ThdlLazyException. |
Method Summary | |
Throwable |
getRealException()
Returns the wrapped exception, the one about which you should actually be concerned. |
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private Throwable wrappedException
Constructor Detail |
public ThdlLazyException()
public ThdlLazyException(String descrip)
descrip
- descriptionpublic ThdlLazyException(String descrip, Throwable realException)
descrip
- descriptionrealException
- the exception the user should actually care aboutpublic ThdlLazyException(Throwable realException)
realException
- the exception the user should actually care aboutMethod Detail |
public Throwable getRealException()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |