The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Use Exception class argument in catch

Posted by Kishori Sharan on July 18, 2001 at 10:09 AM

You must be inheriting all your three exceptions classes from Exception class. So, in catch just pass an argument of type Exception and not of one of three types you have created and this will catch any of your three types of exceptions.

try {
catch ( Exception e ) {
// If you want to take action based on which type
// of exception ( out of 3) was caught then check the
// type of argument e here


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us