Always throw an Exception
(never a Throwable
). You generally don’t catch Throwable
either, but you can. Throwable is the superclass to Exception
and Error
, so you would catch Throwable
if you wanted to not only catch Exception
s but Error
s, that’s the point in having it. The thing is, Error
s are generally things which a normal application wouldn’t and shouldn’t catch, so just use Exception
unless you have a specific reason to use Throwable
.
Related Contents:
- Differences between Exception and Error
- Difference between using Throwable and Exception in a try catch [duplicate]
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- Understanding checked vs unchecked exceptions in Java
- Causes of getting a java.lang.VerifyError
- What are the effects of exceptions on performance in Java?
- How to generate exceptions from RepaintManager
- When to choose checked and unchecked exceptions
- Can I catch multiple Java exceptions in the same catch clause?
- Java List.add() UnsupportedOperationException
- How can I solve “java.lang.NoClassDefFoundError”?
- Handling exceptions from Java ExecutorService tasks
- Is it a bad practice to catch Throwable?
- What could cause java.lang.reflect.InvocationTargetException?
- Difference between java.lang.RuntimeException and java.lang.Exception
- Exception thrown in catch and finally clause
- How to define custom exception class in Java, the easiest way?
- (Unknown Source) in Exception stack trace
- java.util.ConcurrentModificationException not thrown when expected
- How do you assert that a certain exception is thrown in JUnit tests?
- Why doesn’t Java allow generic subclasses of Throwable?
- When should we create our own Java exception classes? [closed]
- Using Joda Date & Time API to parse multiple formats
- Why are Exceptions not Checked in .NET?
- JavaFX Exception in thread “main” java.lang.NoClassDefFoundError: javafx/application/Application
- JDBC driver throws “ResultSet Closed” exception on empty ResultSet
- Java: Exceptions as control flow?
- tomcat server fails to start the server and application in STS [duplicate]
- Eclipse – java.lang.ClassNotFoundException
- Exception NoClassDefFoundError for CacheProvider
- Differences between Runtime/Checked/Unchecked/Error/Exception
- try/catch versus throws Exception
- When to use an assertion and when to use an exception
- Why can’t I throw an exception in a Java 8 lambda expression? [duplicate]
- How to throw a checked exception from a java thread?
- Throws or try-catch
- While constructing the default constructor can not handle exception : type Exception thrown by implicit super constructor
- Rethrowing exceptions in Java without losing the stack trace
- Connection Java – MySQL : Public Key Retrieval is not allowed
- java.net.MalformedURLException: no protocol
- Is it okay to throw NullPointerException programmatically? [closed]
- org.hibernate.MappingException: Unknown entity: annotations.Users
- Why does order matter when catching exceptions?
- Why does TreeSet throw a ClassCastException?
- org.openqa.selenium.UnhandledAlertException: unexpected alert open
- What is the advantage of chained exceptions
- In Java how can I validate a thrown exception with JUnit?
- How can I detect when an Exception’s been thrown globally in Java?
- CompletableFuture already completed with an exception
- Java exception handling