Class ExceptionHandlerRegistration<C,T extends Throwable>

java.lang.Object
org.incendo.cloud.exception.handling.ExceptionHandlerRegistration<C,T>
Type Parameters:
C - the command sender type
T - the exception type

@API(status=STABLE) public final class ExceptionHandlerRegistration<C,T extends Throwable> extends Object
Used to register a ExceptionHandler in the ExceptionController.
  • Method Details

    • of

      public static <C, T extends Throwable> @NonNull ExceptionHandlerRegistration<C,? extends T> of(@NonNull TypeToken<T> exceptionType, @NonNull ExceptionHandler<C,? extends T> exceptionHandler)
      Returns a new registration.
      Type Parameters:
      C - the command sender type
      T - the exception type
      Parameters:
      exceptionType - the type handled by the exception handler
      exceptionHandler - the exception handler
      Returns:
      the created registration
    • builder

      public static <C, T extends Throwable> @NonNull ExceptionHandlerRegistration.ExceptionControllerBuilder<C,T> builder(@NonNull TypeToken<T> exceptionType)
      Returns a builder.

      The builder is immutable, and each method results in a new builder instance.

      Type Parameters:
      C - the command sender type
      T - the exception type
      Parameters:
      exceptionType - the type handled by the exception handler
      Returns:
      the builder
    • exceptionType

      public @NonNull TypeToken<T> exceptionType()
      Returns the exception type handler by this handler.

      More precise exception types will always get higher priority when selecting the exception handlers for any given exception.

      Returns:
      the exception type
    • exceptionHandler

      public @NonNull ExceptionHandler<C,? extends T> exceptionHandler()
      Returns the exception handler.
      Returns:
      the exception handler
    • exceptionFilter

      public @NonNull Predicate<T> exceptionFilter()
      Returns the exception filter.

      Exceptions should only be handled by the exceptionHandler() if the predicate evaluates to true.

      Returns:
      the exception filter