com.holub.tools
Class ThrowableContainer
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.holub.tools.ThrowableContainer
- All Implemented Interfaces:
- Serializable
public class ThrowableContainer
- extends RuntimeException
A convenient container for realying a checked Exception
from a method that can't declare a throws clause to
a calling method that can. This doesn't happen very
often, but occasionally you don't want to declare
an interface method as throwing an exception that
one of the methods called from the implementation
actually throws. Use it like this:
inteface X
{ void interfaceMethod(); // throws nothing.
}
void interfaceMethod()
{ try
{
g(); // throws an IOException
}
catch( IOException e )
{ throw new ThrowableContainer( e );
}
}
void caller(X implementation) thows IOException
{ try
{ implementation.interfaceMethod();
}
catch( ThrowableContainer e )
{ throw (IOException)(e.contents());
}
}
- See Also:
- Serialized Form
©2004 Allen I. Holub. All rights reserved.
This code may be used freely by yourself with the following restrictions:
- Your splash screen, about box, or equivalent, must include
Allen Holub's name, copyright, and URL. For example:
This program contains Allen Holub's SQL package.
(c) 2005 Allen I. Holub. All Rights Reserved.
http://www.holub.com
If your program does not run interactively, then the foregoing
notice must appear in your documentation.
- You may not redistribute (or mirror) the source code.
- You must report any bugs that you find to me. Use the form at
http://www.holub.com/company/contact.html
or send email.
- The software is supplied as is. Neither Allen Holub nor
Holub Associates are responsible for any bugs (or any problems
caused by bugs, including lost productivity or data)
in any of this code.
|
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
ThrowableContainer
public ThrowableContainer(Throwable contents)
contents
public Throwable contents()