Interrupt: Throws an instance of an exception class and terminates execution of the existing program;
Recovery: Instead of throwing an instance of an exception class, call a method to resolve the problem or resolve the problem in place.
In Java, for the client programmers who want to invoke the method, we have to inform them that they may "throw" the violation in their own way. This is a polite approach that only allows the client programmer to know exactly what code to write to capture all potential violations.
Catch (Exception e) {System.out.println ("Caught an Exception");
This code captures any violation, so it is best to place it at the end of the controller list when it is actually used, to prevent any special offending controllers that follow it from invalidating. For all the offending classes commonly used by programmers, because the exception class is their basis, we don't get too much information about the violation, but we can call the method from its underlying class Throwable:
String GetMessage ()
Get the detailed message.
String toString ()
Returns a brief description of the Throwable, including a detailed message, if any.
void printstacktrace () void printstacktrace (printstream)
Prints the call stack path for Throwable and Throwable. The call stack shows the order of the method calls that take us to the offending place.
The first version prints out the standard error, and the second prints out our selection process. If you are working under Windows, you cannot redirect standard errors. Therefore, we generally prefer to use the second version and send the results to System.out so that the output can be redirected to any path we want.
Interrupts and restores of Java exceptions