Package org.apache.pekko.japi
Class Throwables
java.lang.Object
org.apache.pekko.japi.Throwables
Helper class for determining whether a
Throwable is fatal or not.
User should only catch the non-fatal one,and keep rethrow the fatal one.
Fatal errors are errors like VirtualMachineError
(for example, OutOfMemoryError and StackOverflowError, subclasses of VirtualMachineError), ThreadDeath,
LinkageError, InterruptedException, ControlThrowable.
Note. this helper keep the same semantic with NonFatal in Scala.
For example, all harmless Throwables can be caught by:
try {
// dangerous stuff
} catch(Throwable e) {
if (Throwables.isNonFatal(e)){
log.error(e, "Something not that bad.");
} else {
throw e;
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true if the providedThrowableis to be considered fatal, or false if it is to be considered non-fatalstatic booleanisNonFatal(Throwable throwable) Returns true if the providedThrowableis to be considered non-fatal, or false if it is to be considered fatalstatic <T extends Throwable,R>
RThrows the givenThrowable, without requiring the caller to declare it in athrowsclause.
-
Constructor Details
-
Throwables
public Throwables()
-
-
Method Details
-
isNonFatal
Returns true if the providedThrowableis to be considered non-fatal, or false if it is to be considered fatal -
isFatal
Returns true if the providedThrowableis to be considered fatal, or false if it is to be considered non-fatal -
sneakyThrow
Throws the givenThrowable, without requiring the caller to declare it in athrowsclause.- Parameters:
t- theThrowableto throw- Returns:
- never returns normally, but has return type
Rto allow usage in expressions - Throws:
T- the type of theThrowableto throw- Since:
- 2.0.0
-