Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle ExceptionInInitializerError ?

 
jami siva
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Below is my code, in this iam unable to catch ExceptionInInitializerError, iam only to catch NullPointerException Only,
Can any one make edjustments to this code to handle ExceptionInInitializerError.
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can't because ExceptionInInitializerError is a chaining exception.


maybe you can try to use
NullPointerException.getCause() to return a Throwable object and cast it to ExceptionInInitializerError





or a better approach is

 
jami siva
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Lee Kian Giap ,

I Understood this one.

Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic