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;
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Throwables$Static reference to the singleton instance of this Scala object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the providedThrowableis to be considered fatal, or false if it is to be considered non-fatalbooleanisNonFatal(Throwable throwable) Returns true if the providedThrowableis to be considered non-fatal, or false if it is to be considered fatal<T extends Throwable,R>
RThrows the givenThrowable, without requiring the caller to declare it in athrowsclause.
-
Field Details
-
MODULE$
Static reference to the singleton instance of this Scala object.
-
-
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
-