Package com.mastfrog.util.preconditions
Class Exceptions
java.lang.Object
com.mastfrog.util.preconditions.Exceptions
Simple utilities for dealing with exceptions.
- Author:
- Tim Boudreau
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceService provider which logs exceptions; the default implementation uses the JDK's logger. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Throwable>
voidstatic <ReturnType>
ReturnTypeDirty trick to rethrow a checked exception.static <ReturnType>
ReturnTypeUnwinds any causing-exception and chucks the root cause throwable.static <ReturnType>
ReturnTypechuckUnless(Throwable t, ReturnType what, BooleanSupplier predicate) static voidprintStackTrace(Class<?> caller, String msg, Throwable t) static voidprintStackTrace(Class<?> caller, Throwable t) static voidprintStackTrace(String msg, Throwable t) static void
-
Method Details
-
printStackTrace
-
printStackTrace
-
printStackTrace
-
printStackTrace
-
chuck
Dirty trick to rethrow a checked exception. Makes it possible to implement an interface such as Iterable (which cannot throw exceptions) without the useless re-wrapping of exceptions in RuntimeException.- Parameters:
t- A throwable. This method will throw it without requiring a catch block.
-
chuck
- Throws:
T extends Throwable
-
chuckUnless
public static <ReturnType> ReturnType chuckUnless(Throwable t, ReturnType what, BooleanSupplier predicate) -
chuckOriginal
Unwinds any causing-exception and chucks the root cause throwable.- Type Parameters:
ReturnType- The type to pretend to return (this method always exits abnormally), so methods can be written cleanly, e.g.return Exceptions.chuck(someException).- Parameters:
t-- Returns:
-