Interface ExceptionLoggerDelegate
-
public interface ExceptionLoggerDelegateThis class is internally used by theExceptionLogger. You usually don't want to interact with this object.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> java.util.function.Function<java.lang.Throwable,T>get(java.util.function.Predicate<java.lang.Throwable> logFilter, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> ignoredThrowableTypes, java.lang.StackTraceElement[] stackTrace)Returns a function that can be used in theCompletableFuture.exceptionally(Function)method.java.lang.Thread.UncaughtExceptionHandlergetUncaughtExceptionHandler()Returns an uncaught exception handler that can be used in theThread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler)andThread.setUncaughtExceptionHandler(UncaughtExceptionHandler)methods.static java.lang.ThrowableunwrapThrowable(java.lang.Throwable throwable)UnwrapsCompletionExceptions,InvocationTargetExceptionsandExecutionExceptionsand returns the actual cause, or the given argument itself if it is not one of the listed exceptions types.
-
-
-
Method Detail
-
get
<T> java.util.function.Function<java.lang.Throwable,T> get(java.util.function.Predicate<java.lang.Throwable> logFilter, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> ignoredThrowableTypes, java.lang.StackTraceElement[] stackTrace)Returns a function that can be used in theCompletableFuture.exceptionally(Function)method. It unwrapsCompletionExceptions,InvocationTargetExceptionsandExecutionExceptionsfirst, and then adds a freshCompletionExceptionas wrapper with the stacktrace of the caller of this method and logs it afterwards. The rewrapped exception is only logged if the givenlogFilterpredicate allows the exception and the class of it is not in theignoredThrowableTypes.- Type Parameters:
T- The return type of the function.- Parameters:
logFilter- The predicate the unwrapped exception is tested against.ignoredThrowableTypes- The throwable types that should never be logged.stackTrace- The stack trace pointing to the caller of this method.- Returns:
- A function which logs the given throwable and returns
null.
-
getUncaughtExceptionHandler
java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
Returns an uncaught exception handler that can be used in theThread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler)andThread.setUncaughtExceptionHandler(UncaughtExceptionHandler)methods. It unwrapsCompletionExceptions,InvocationTargetExceptionsandExecutionExceptionsfirst and logs it afterwards, including the thread name.- Returns:
- An
Thread.UncaughtExceptionHandlerwhich logs the given throwable.
-
unwrapThrowable
static java.lang.Throwable unwrapThrowable(java.lang.Throwable throwable)
UnwrapsCompletionExceptions,InvocationTargetExceptionsandExecutionExceptionsand returns the actual cause, or the given argument itself if it is not one of the listed exceptions types. If the bottom-most exception to unwrap does not have a cause, it is returned itself instead.- Parameters:
throwable- The throwable to unwrap.- Returns:
- The unwrapped throwable.
-
-