• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error Exception  RSS feed

 
Gheyath Nasani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i catch "Error Exception" ? if not , why ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To find out whether you can catch an Error, write a small program to try it out.

Trying things out yourself is a good way to learn how something works.
 
Campbell Ritchie
Marshal
Posts: 56587
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read the Java® Language Specification to see whether an Error is acceptable in the header of the catch statement. Maybe Jesper's suggestion of trying it out will be quicker.
But before you catch anything, read the documentation for this class. You would have to precede any catch with this:-I can give you some code which can be relied upon to throw an Error:-Additional: in the Java® Language Specification page linked to, scroll up and look for exception parameter.
 
Campbell Ritchie
Marshal
Posts: 56587
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall leave you to go through the inheritance hierarchy and find out why nobody has told you to rethrow a ThreadDeath instance before catching an Exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!