0 votes
1 view
in Java by (4.1k points)

Sometimes I see

try {

} catch(Throwable e) {

}

And sometimes

try {

} catch(Exception e) {

}

What is the difference

1 Answer

0 votes
by (46.1k points)

By making Throwable it involves things that subclass Error. You should usually not do that, except possibly at the very highest "catch-all" level of a string where you want to log or unless handle absolutely everything that can go wrong. It would be more expected in a framework type application (for example an application server or an examination framework) where it can be running unknown code and should not be influenced by anything that works inside with that code, as much as feasible.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...