Class OpenAIException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.agentscope.extensions.model.openai.exception.OpenAIException
All Implemented Interfaces:
io.agentscope.core.model.ModelHttpException, Serializable
Direct Known Subclasses:
AuthenticationException, BadRequestException, InternalServerException, NotFoundException, PermissionDeniedException, RateLimitException, UnprocessableEntityException

public class OpenAIException extends RuntimeException implements io.agentscope.core.model.ModelHttpException
Base exception for all OpenAI API errors.

This is the root exception class for OpenAI-related errors. Specific error conditions are represented by subclasses.

See Also:
  • Constructor Details

    • OpenAIException

      public OpenAIException(String message)
    • OpenAIException

      public OpenAIException(String message, Throwable cause)
    • OpenAIException

      public OpenAIException(String message, int statusCode, String responseBody)
    • OpenAIException

      public OpenAIException(String message, int statusCode, String errorCode, String responseBody)
    • OpenAIException

      public OpenAIException(String message, String errorCode, String responseBody)
  • Method Details

    • create

      public static OpenAIException create(Integer statusCode, String message, String errorCode, String responseBody)
      Factory method to create appropriate exception subclass based on status code.
      Parameters:
      statusCode - HTTP status code
      message - Error message
      errorCode - OpenAI error code
      responseBody - Full response body
      Returns:
      Appropriate exception subclass
    • getStatusCode

      public Integer getStatusCode()
      Specified by:
      getStatusCode in interface io.agentscope.core.model.ModelHttpException
    • getErrorCode

      public String getErrorCode()
    • getResponseBody

      public String getResponseBody()