Originally posted by sudarsan tettu:
What is use of catch(Thowable t) over catch(Exception ex)
catch(Exception e) : catches both runtime and checked exceptions.In ideal programs runtime exceptions are not to be caught.Excluding special conditions like in case of a B2B application where the client in expecting something which would suggest that a exceptions has taken place (like error code ), but actual exception might not be making sense for the client.So in those cases you might want to catch the exception and send error code.
Another conditions is when you want your program to continue even after a Fatal blow.In that case also catching runtime exceptions might help.
catch(Throwable t) : catched runtime , checked exceptions and errors too.