[Advanced-java] How To Determine The Appropriate Exception?

KCE kurt at searchbug.com
Fri Aug 8 15:26:06 2003


On Fri, 8 Aug 2003 16:15:11 +0700 (WIT)
  Adrian Soetanto <adrian@peter.petra.ac.id> wrote:
>Hi,
>
>Could anyone help me how to determine the appropriate 
>Exception to get the 
>error message thrown by any methods?
>
>Since the Throwable class is the superclass of all errors 
>and exceptions 
>in the Java language, could we use it in every exception 
>handling?
>
>--
>Thank You,
>  Adrian
>
>_______________________________________________
>Advanced-java mailing list
>Advanced-java@lists.xcf.berkeley.edu
>http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java


Yeah, in fact, you can use the Exception base class:

try {
   myObject.myMethod();
} catch(Exception e) {
   e.printStackTrace();
}

Just try to avoid doing this whenever possible!  Its 
really easy to wind up with exceptions flying everywhere 
and NO IDEA where they came from!!!
 
 
______________________________________________________
Find People and Businesses at http://www.SearchBug.com
Innovative Messaging Solutions by GMSI, http://www.gmsi1.com