Class SwallowedExceptionHandleUtils

java.lang.Object
io.foldright.cffu2.eh.SwallowedExceptionHandleUtils

public final class SwallowedExceptionHandleUtils extends Object
Utilities to handle swallowed exceptions from MULTIPLE CompletionStages (including CompletableFutures and Cffus).

These utilities are designed for noncritical tasks like reporting and logging exceptions. For business logic exception handling, use the standard exception handling methods for SINGLE CompletionStages instead: exceptionally, catching, or handle.

Author:
Jerry Lee (oldratlee at gmail dot com)
See Also:
  • Method Details

    • handleAllSwallowedExceptions

      public static void handleAllSwallowedExceptions(String where, CompletionStage<?>... inputs)
      Handles all exceptions from multiple input CompletionStages as swallowed exceptions, using cffuSwallowedExceptionHandler() and calling back it with null attachment.
      Parameters:
      where - the location where the exception occurs
    • handleAllSwallowedExceptions

      public static void handleAllSwallowedExceptions(String where, ExceptionHandler exceptionHandler, CompletionStage<?>... inputs)
      Handles all exceptions from multiple input CompletionStages as swallowed exceptions, calling back the exceptionHandler with null attachment.
      Parameters:
      where - the location where the exception occurs
      exceptionHandler - the exception handler
    • handleAllSwallowedExceptions

      public static void handleAllSwallowedExceptions(String where, @Nullable Object[] attachments, ExceptionHandler exceptionHandler, CompletionStage<?>... inputs)
      Handles all exceptions from multiple input CompletionStages as swallowed exceptions.
      Parameters:
      where - the location where the exception occurs
      attachments - the attachment objects
      exceptionHandler - the exception handler
    • handleSwallowedExceptions

      public static void handleSwallowedExceptions(String where, CompletableFuture<?> output, CompletionStage<?>... inputs)
      Handles swallowed exceptions from multiple input CompletionStages that are discarded (not propagated) by the output CompletionStage, using cffuSwallowedExceptionHandler() and calling back it with null attachment.
      Parameters:
      where - the location where the exception occurs
    • handleSwallowedExceptions

      public static void handleSwallowedExceptions(String where, ExceptionHandler exceptionHandler, CompletableFuture<?> output, CompletionStage<?>... inputs)
      Handles swallowed exceptions from multiple input CompletionStages that are discarded (not propagated) by the output CompletionStage, calling back the exceptionHandler with null attachment.
      Parameters:
      where - the location where the exception occurs
      exceptionHandler - the exception handler
    • handleSwallowedExceptions

      public static void handleSwallowedExceptions(String where, @Nullable Object[] attachments, ExceptionHandler exceptionHandler, CompletableFuture<?> output, CompletionStage<?>... inputs)
      Handles swallowed exceptions from multiple input CompletionStages that are discarded (not propagated) by the output CompletionStage.
      Parameters:
      where - the location where the exception occurs
      attachments - the attachment objects
      exceptionHandler - the exception handler
    • cffuSwallowedExceptionHandler

      public static ExceptionHandler cffuSwallowedExceptionHandler()
      Returns an exception handler that logs swallowed exceptions from CompletionStages at warning level using the cffu logger.