What is the difference between catch exception e catch error err and catch throwable t? |
Answer
Java Almanac has a good summary.
See http://javaalmanac.com/egs/Java%20Language/CatchThrowable.html?l=new
"All errors and exceptions extend from Throwable. By catching Throwable, it is possible to handle all unexpected conditions.
There are several scenarios where it is good practice to catch Throwable. For example, in a server application, the threads that handle requests should catch Throwable and relay any errors or exceptions to the client. Another scenario is a long-running thread that performs some background activity. Such threads should catch Throwable, log any errors or exceptions, and then continue functioning.
It is rarely good practice for a method in a library to catch Throwable. In general, errors and exceptions should not be masked from the caller."
|
|
|
First answer by ID1087241046. Last edit by ID1087241046. Question popularity: 89 [recommend question]
|
Research your answer: |
Can you answer other questions about programming?
|
|


