org.thdl.util
Class ThdlLazyException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Error
              |
              +--org.thdl.util.ThdlLazyException
All Implemented Interfaces:
Serializable

public final class ThdlLazyException
extends Error

Author:
David Chandler

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.

See Also:
Serialized Form

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
 

Constructor Detail

ThdlLazyException

public ThdlLazyException()
Constructor for ThdlLazyException.


ThdlLazyException

public ThdlLazyException(String descrip)
Constructor for ThdlLazyException.

Parameters:
descrip - description

ThdlLazyException

public ThdlLazyException(String descrip,
                         Throwable realException)
Constructor for ThdlLazyException.

Parameters:
descrip - description
realException - the exception the user should actually care about

ThdlLazyException

public ThdlLazyException(Throwable realException)
Constructor for ThdlLazyException.

Parameters:
realException - the exception the user should actually care about
Method Detail

getRealException

public Throwable getRealException()
Returns the wrapped exception, the one about which you should actually be concerned.



These API docs were created 02/02/2003 08:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo