AS AgentScopeAPI 手册 / API Reference

OpenAIException

public class OpenAIException extends RuntimeException implements ModelHttpException
源码Source 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.

参数Parameters
名称Name类型Type说明Description
messageString消息(类型 `String`)。The message.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:31–36

OpenAIException

public OpenAIException(String message, Throwable cause)

初始化 OpenAIException 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
messageString消息(类型 `String`)。The message.
causeThrowablecause(类型 `Throwable`)。The cause.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:38–43

OpenAIException

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

初始化 OpenAIException 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
messageString消息(类型 `String`)。The message.
statusCodeint状态 Code(类型 `int`)。The status code.
responseBodyString响应正文(类型 `String`)。The response body.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:45–50

OpenAIException

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

初始化 OpenAIException 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
messageString消息(类型 `String`)。The message.
statusCodeint状态 Code(类型 `int`)。The status code.
errorCodeString错误 Code(类型 `String`)。The error code.
responseBodyString响应正文(类型 `String`)。The response body.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:52–57

OpenAIException

public OpenAIException(String message, String errorCode, String responseBody)

初始化 OpenAIException 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
messageString消息(类型 `String`)。The message.
errorCodeString错误 Code(类型 `String`)。The error code.
responseBodyString响应正文(类型 `String`)。The response body.
源码Source 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)
static

创建并返回实例。

Factory method to create appropriate exception subclass based on status code.

参数Parameters
名称Name类型Type说明Description
statusCodeInteger状态 Code(类型 `Integer`)。HTTP status code
messageString消息(类型 `String`)。Error message
errorCodeString错误 Code(类型 `String`)。OpenAI error code
responseBodyString响应正文(类型 `String`)。Full response body
返回Returns OpenAIException
返回OpenAIException。Appropriate exception subclass
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:75–93

getStatusCode

public Integer getStatusCode()

获取 getStatusCode。

Returns the status code.

返回Returns Integer
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:95–98

getErrorCode

public String getErrorCode()

获取 getErrorCode。

Returns the error code.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:100–102

getResponseBody

public String getResponseBody()

获取响应正文。

Returns the response body.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/model/openai/exception/OpenAIException.java:104–106

继承成员Inherited Members

继承自Methods inherited from ModelHttpException
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.