Very commonly I see code which puts data into the message of an Exception as a way to pass information. This was certainly the case with the original Exception
class which provided no way to hold context. Recent JDKs fixed that with Exception.getCause()
. But I didn't realize the general usefulness of this approach until reading the changes so far in JDK5 Beta2. After all, exceptions are just classes; they too can have more methods. In fact, this is just what UnknownFormatConversionException.getConversion
made me see. Useful information passed on an exception to aid in recovery, logging, etc. is just the ticket.
Wednesday, August 18, 2004
Smarter exceptions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment