Java Exception Handling
Posted on 2006-07-17
In main method, I have
String errorMsg = null;
System.out.println("Exception: "+ ex);
//this is what I want to do.
// if exception occurs in m1 --->set errorMsg "Exception in method m1";
//if exception occurs in m2 --> set errorMsg "Exception in method m2";
System.out.println("Error Message: "+errorMsg);
All the submethods, m1, m2... have return type as void.
Now, according to this try-catch block, here if any exception occurs in any of the methods, the rest of the methods should not execute.
How do I set the error Message and print exactly