Class ExceptionHandlingExamples
java.lang.Object
net.jrodolfo.java_evolution.java07.ExceptionHandlingExamples
Demonstrates Java 7 exception-handling improvements from Project Coin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFailure modes used by the example. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionHandles two checked exception types with one catch block.voidRethrows an exception parameter without widening the declared throws clause beyond the precise checked exceptions that can be thrown.
-
Constructor Details
-
ExceptionHandlingExamples
public ExceptionHandlingExamples()
-
-
Method Details
-
recoverWithMultiCatch
Handles two checked exception types with one catch block.- Parameters:
failure- failure mode- Returns:
- shared recovery message
-
rethrowPrecisely
public void rethrowPrecisely(ExceptionHandlingExamples.FailureMode failure) throws IOException, SQLException Rethrows an exception parameter without widening the declared throws clause beyond the precise checked exceptions that can be thrown.- Parameters:
failure- failure mode- Throws:
IOException- when I/O failsSQLException- when database work fails
-