Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

Sometimes I see

try {

} catch(Throwable e) {

}

And sometimes

try {

} catch(Exception e) {

}

What is the difference

1 Answer

0 votes
by (46k 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
0 votes
1 answer

Browse Categories

...