Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Exception doubt

 
Kaushik Baral
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can i create a custom exception extending java.lang.Throwable? if yes then why we do it using Exception or RuntimeException. what will be the problem if we do it using Throwable always?

thanks a lot in advance
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because many methods only deal with Exceptions, you will have to introduce special handling for your Throwable subclass. It will count as "checked" of course.

Of course you can subclass Throwable, but that should only be done under the justification of
I only wanted to see what happens if . . .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic