• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Throwable and Exception class

 
balaji sudheer bandi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between Throwable and Exception classes.
What is the good procedure to develop user defined exceptions ,by either extending Throwable or Exception class.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't really the right place to ask that question. We have a forum dedicated to Java In General (beginner) questions. When you ask a question in the most appropriate forum, not only are you more likely to get an answer, you'll probably get a better quality answer, since that's where the experts on the subject will be looking. Also, it keeps from cluttering other forums with questions that don't pertain to the forum topic.

But, for a short answer: Throwable is the root of all sequence-interrupting events, including java.lang.Exception. Usually, application developers will want to subclass java.lang.Exception. For more details, I encourage you to ask the folks in the Java In General forum.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the forum suggested by Tim

Mark
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, when you create your own exception class, you should either subclass Exception (if you want a checked exception) or RuntimeException (if you want an unchecked exception). Throwable is the superclass for all exceptions and errors and should not be subclassed directly.
 
Krithika Srinath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add to the previous notes..

It is rarely good practice for a method to catch Throwable. One such scenario could be when you want to log the error message. In general, errors and exceptions should not be masked from the caller.

You can checkthis doc for more details.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic