Interface ExceptionLoggerDelegate


  • public interface ExceptionLoggerDelegate
    This class is internally used by the ExceptionLogger. 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 the CompletableFuture.exceptionally(Function) method.
      java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
      Returns an uncaught exception handler that can be used in the Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler) and Thread.setUncaughtExceptionHandler(UncaughtExceptionHandler) methods.
      static java.lang.Throwable unwrapThrowable​(java.lang.Throwable throwable)
      Unwraps CompletionExceptions, InvocationTargetExceptions and ExecutionExceptions and 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 the CompletableFuture.exceptionally(Function) method. It unwraps CompletionExceptions, InvocationTargetExceptions and ExecutionExceptions first, and then adds a fresh CompletionException as wrapper with the stacktrace of the caller of this method and logs it afterwards. The rewrapped exception is only logged if the given logFilter predicate allows the exception and the class of it is not in the ignoredThrowableTypes.
        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 the Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler) and Thread.setUncaughtExceptionHandler(UncaughtExceptionHandler) methods. It unwraps CompletionExceptions, InvocationTargetExceptions and ExecutionExceptions first and logs it afterwards, including the thread name.
        Returns:
        An Thread.UncaughtExceptionHandler which logs the given throwable.
      • unwrapThrowable

        static java.lang.Throwable unwrapThrowable​(java.lang.Throwable throwable)
        Unwraps CompletionExceptions, InvocationTargetExceptions and ExecutionExceptions and 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.