--
All exceptions come from the "mother class" called
All exceptions come from the "mother class" called
java.lang.Throwable and one of two subclasses called java.lang.Error and java.lang.Exception. A block of code that is executed when an exception occurs is called an Exception handler. By catching java.lang.Throwable, it is possible to handle all unexpected conditions. ...
try {
}
catch(Throwable e) {
...
}
...There are some special exceptions that used by the JVM, those are the sub-classes of java.lang.Error. We are not suppose the catch them in our real code and we usually catch java.lang.Exception for all application and runtime exceptions....
try {
}
catch(Exception e) {
...
}
...
You know this is plain wrong, right? Pokemon exception handling is the worst thing you can do (about exceptions, obviously).
ReplyDeleteYes..you are right dear...just i want to tell the all possible ways t catch all exceptions..
ReplyDeleteSay you catch a Throwable and you want to rethrow it, you can call Thread.currentThread().stop(t). This triggers the current thread to throw the Throwable t. Note: this bypasses the compilers checked exception, so handle with care.
ReplyDelete