Interface ClientExceptionFactory<E extends ClientException,R extends ClientError>

Type Parameters:
E - The subtype of ClientException to be created by this factory.
R - The subtype of ClientError payload that can be processed by this factory.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ClientExceptionFactory<E extends ClientException,R extends ClientError>
A factory whose implementations can provide customized exception types and error mapping logic for different service clients or error scenarios.
  • Method Summary

    Modifier and Type
    Method
    Description
    default E
    build(String message)
    Creates an exception with a message and optional cause.
    default E
    build(String message, Throwable cause)
    Creates an exception with a message and optional cause.
    build(String message, R clientError, Throwable cause)
    Creates an exception from a given message and an HTTP error response that has been successfully deserialized into a ClientError object.
  • Method Details

    • build

      @Nonnull default E build(@Nonnull String message, @Nullable Throwable cause)
      Creates an exception with a message and optional cause.
      Parameters:
      message - A descriptive message for the exception.
      cause - An optional cause of the exception, can be null if not applicable.
      Returns:
      An instance of the specified ClientException type
    • build

      @Nonnull default E build(@Nonnull String message)
      Creates an exception with a message and optional cause.
      Parameters:
      message - A descriptive message for the exception.
      Returns:
      An instance of the specified ClientException type
    • build

      @Nonnull E build(@Nonnull String message, @Nullable R clientError, @Nullable Throwable cause)
      Creates an exception from a given message and an HTTP error response that has been successfully deserialized into a ClientError object.
      Parameters:
      message - A descriptive message for the exception.
      clientError - The structured ClientError object deserialized from the response, null if not exist.
      cause - An optional cause of the exception, can be null if not applicable.
      Returns:
      An instance of the specified ClientException type