aspose file tools*
The moose likes Java in General and the fly likes Error Class in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error Class in java" Watch "Error Class in java" New topic
Author

Error Class in java

S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Hi everybody ,
we know classes that derived from Error represent unusual situations that are not caused by program errors such as JVM running out of memory .

My question is then why Error class is included by Sun ? Is there any specific reason ?

Another thing is : Generally our application won't be able to recover from an Error.

Is this statement is correct ?

If correct then basically RuntimeException and Error are both same .


Please give your comments .

Thanks & regards,
S
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
No. A RuntimeException and an Error are very different. A RuntimeException is caused by an error (usually incorrect code) occurring entirely inside the runtime environment. An Error may occur outwith the runtime environment, eg running out of memory.
Read the API documentation for Error and RuntimeException and a few of their subclasses. It also means that catch (Exception ex) will allow Errors to propagate.
You should not normally use catch (Error er), but if you ever do, remember to propagate instances of ThreadDeath.
S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Thanks for the reply Campbell Ritchie .

Could you please explain :
Campbell Ritchie wrote:You should not normally use catch (Error er), but if you ever do, remember to propagate instances of ThreadDeath.


regards,
S

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
It's in the API documentation for ThreadDeath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error Class in java