Class ClientException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OpenAiClientException, OrchestrationClientException

public class ClientException extends RuntimeException
Generic exception for errors occurring when using AI SDK clients.
Since:
1.1.0
See Also:
  • Constructor Details

    • ClientException

      public ClientException()
    • ClientException

      public ClientException(String message)
    • ClientException

      public ClientException(Throwable cause)
    • ClientException

      public ClientException(String message, Throwable cause)
  • Method Details

    • setClientError

      @Nonnull public <T extends ClientException> T setClientError(@Nullable ClientError clientError)
      Sets the original HTTP request that caused this exception.
      Type Parameters:
      T - the type of the exception, typically a subclass of ClientException
      Parameters:
      clientError - the original structured error payload received from the remote service, can be null if not available.
      Returns:
      the current instance of ClientException with the changed ClientError data
    • setHttpResponse

      @Nonnull public <T extends ClientException> T setHttpResponse(@Nullable org.apache.hc.core5.http.ClassicHttpResponse httpResponse)
      Sets the original HTTP request that caused this exception.
      Type Parameters:
      T - the type of the exception, typically a subclass of ClientException
      Parameters:
      httpResponse - the original HTTP response that caused this exception, can be null if not available.
      Returns:
      the current instance of ClientException with the changed HTTP response
    • setHttpRequest

      @Nonnull public <T extends ClientException> T setHttpRequest(@Nullable org.apache.hc.core5.http.ClassicHttpRequest httpRequest)
      Sets the original HTTP request that caused this exception.
      Type Parameters:
      T - the type of the exception, typically a subclass of ClientException
      Parameters:
      httpRequest - the original HTTP request that caused this exception, can be null if not available.
      Returns:
      the current instance of ClientException with the changed HTTP request
    • getClientError

      @Nullable public ClientError getClientError()
      Wraps a structured error payload received from the remote service, if available. This can be used to extract more detailed error information.
      Since:
      1.10.0
    • getHttpResponse

      @Nullable public org.apache.hc.core5.http.ClassicHttpResponse getHttpResponse()
      The original HTTP response that caused this exception, if available.
      Since:
      1.10.0
    • getHttpRequest

      @Nullable public org.apache.hc.core5.http.ClassicHttpRequest getHttpRequest()
      The original HTTP request that caused this exception, if available.
      Since:
      1.10.0