Intellipaat Back

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

In what situations should one catch java.lang.Error on an application?

1 Answer

0 votes
by (13.1k points)

Generally, never.

However, sometimes you need to catch specific errors.

If you are writing framework code, it might be wise to catch LinkageError. I have also seen some stupid 3rd-party code throwing subclasses of Error, so you’ll have to handle those as well.

By the way, I am not sure it is not possible to recover from OutOfMemoryError.

Want to learn Java? Check out the Java certification from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer

Browse Categories

...