In what situations should one catch java.lang.Error on an application?
In what situations should one catch java.lang.Error on an application?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Generally, never.
However, sometimes you need to catch specific errors.
If you’re writing framework-ish code (loading 3rd party classes), it might be wise to catch
LinkageError(no class def found, unsatisfied link, incompatible class change).I’ve also seen some stupid 3rd-party code throwing subclasses of
Error, so you’ll have to handle those as well.By the way, I’m not sure it isn’t possible to recover from
OutOfMemoryError.