Package com.sap.ai.sdk.core.common

# Class ClientException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.sap.ai.sdk.core.common.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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClientException()`
  `ClientException(String message)`
  `ClientException(String message, Throwable cause)`
  `ClientException(Throwable cause)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClientError`
  `getClientError()`
  Wraps a structured error payload received from the remote service, if available.
  `org.apache.hc.core5.http.ClassicHttpRequest`
  `getHttpRequest()`
  The original HTTP request that caused this exception, if available.
  `org.apache.hc.core5.http.ClassicHttpResponse`
  `getHttpResponse()`
  The original HTTP response that caused this exception, if available.
  `<T extends ClientException>
  T`
  `setClientError(ClientError clientError)`
  Sets the original HTTP request that caused this exception.
  `<T extends ClientException>
  T`
  `setHttpRequest(org.apache.hc.core5.http.ClassicHttpRequest httpRequest)`
  Sets the original HTTP request that caused this exception.
  `<T extends ClientException>
  T`
  `setHttpResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse)`
  Sets the original HTTP request that caused this exception.

  ### Methods inherited from class java.lang.Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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