OpenAIException
public class OpenAIException extends RuntimeException implements ModelHttpException
io/agentscope/extensions/model/openai/exception/OpenAIException.java:26–107用于所有 OpenAI API 错误的基类异常。位于 io.agentscope.extensions.model.openai.exception 包,继承自 RuntimeException,实现 ModelHttpException。核心成员包括 create、getStatusCode、getErrorCode、getResponseBody、OpenAIException。
Base exception for all OpenAI API errors.
This is the root exception class for OpenAI-related errors. Specific error conditions are represented by subclasses.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public OpenAIException(String message) | 初始化 `OpenAIException` 实例。 Creates a new instance. |
public OpenAIException(String message, Throwable cause) | 初始化 `OpenAIException` 实例。 Creates a new instance. |
public OpenAIException(String message, int statusCode, String responseBody) | 初始化 `OpenAIException` 实例。 Creates a new instance. |
public OpenAIException(String message, int statusCode, String errorCode, String responseBody) | 初始化 `OpenAIException` 实例。 Creates a new instance. |
public OpenAIException(String message, String errorCode, String responseBody) | 初始化 `OpenAIException` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static OpenAIException create(Integer statusCode, String message, String errorCode, String responseBody)static | 创建并返回实例。 Factory method to create appropriate exception subclass based on status code. |
public Integer getStatusCode() | 获取 `getStatusCode`。 Returns the status code. |
public String getErrorCode() | 获取 `getErrorCode`。 Returns the error code. |
public String getResponseBody() | 获取响应正文。 Returns the response body. |
构造器详情Constructor Detail
OpenAIException
public OpenAIException(String message)
初始化 OpenAIException 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 消息(类型 `String`)。The message. |
io/agentscope/extensions/model/openai/exception/OpenAIException.java:31–36OpenAIException
public OpenAIException(String message, Throwable cause)
初始化 OpenAIException 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 消息(类型 `String`)。The message. |
cause | Throwable | cause(类型 `Throwable`)。The cause. |
io/agentscope/extensions/model/openai/exception/OpenAIException.java:38–43OpenAIException
public OpenAIException(String message, int statusCode, String responseBody)
初始化 OpenAIException 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 消息(类型 `String`)。The message. |
statusCode | int | 状态 Code(类型 `int`)。The status code. |
responseBody | String | 响应正文(类型 `String`)。The response body. |
io/agentscope/extensions/model/openai/exception/OpenAIException.java:45–50OpenAIException
public OpenAIException(String message, int statusCode, String errorCode, String responseBody)
初始化 OpenAIException 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 消息(类型 `String`)。The message. |
statusCode | int | 状态 Code(类型 `int`)。The status code. |
errorCode | String | 错误 Code(类型 `String`)。The error code. |
responseBody | String | 响应正文(类型 `String`)。The response body. |
io/agentscope/extensions/model/openai/exception/OpenAIException.java:52–57OpenAIException
public OpenAIException(String message, String errorCode, String responseBody)
初始化 OpenAIException 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 消息(类型 `String`)。The message. |
errorCode | String | 错误 Code(类型 `String`)。The error code. |
responseBody | String | 响应正文(类型 `String`)。The response body. |
io/agentscope/extensions/model/openai/exception/OpenAIException.java:59–64方法详情Method Detail
create
public static OpenAIException create(Integer statusCode, String message, String errorCode, String responseBody)
创建并返回实例。
Factory method to create appropriate exception subclass based on status code.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
statusCode | Integer | 状态 Code(类型 `Integer`)。HTTP status code |
message | String | 消息(类型 `String`)。Error message |
errorCode | String | 错误 Code(类型 `String`)。OpenAI error code |
responseBody | String | 响应正文(类型 `String`)。Full response body |
OpenAIExceptionio/agentscope/extensions/model/openai/exception/OpenAIException.java:75–93getStatusCode
public Integer getStatusCode()
获取 getStatusCode。
Returns the status code.
Integerio/agentscope/extensions/model/openai/exception/OpenAIException.java:95–98getErrorCode
public String getErrorCode()
获取 getErrorCode。
Returns the error code.
Stringio/agentscope/extensions/model/openai/exception/OpenAIException.java:100–102getResponseBody
public String getResponseBody()
获取响应正文。
Returns the response body.
Stringio/agentscope/extensions/model/openai/exception/OpenAIException.java:104–106