Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to handle errors in java  RSS feed

 
Biswadarshi parida
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
I have general doubt ,i.e how to handle errors(not exception) in java(like outof memory,linkage error etc..,we can prevent the error like out of memory.but some one want to handle it inside the code.so how to do that?is there any mechanism given by java soft?

I hope i have posted the question in correct forum.


Thanks in Advance,

Biswadarshi Parida

 
pradeep setti
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can handle errors in one way that is:
Catching the Throwable class which is the super class for Exceptions and Error classes.Or by Catching the Error class itself.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Biswadarshi parida, please be more careful choosing a forum to post your question in this is not really an "EJB and Other Java EE Technologies" question.
Catching Throwable is not a good thing to do - there is a good article here explaining why.

Generally Errors are bad, but your application can carry on regardless so you shouldn't need to catch these. If you have logic whereby you do, then you should probably be explicitly catching the Error you are expecting, rather than catching everything.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!