AS AgentScopeAPI 手册 / API Reference

ModelException

public class ModelException extends RuntimeException
源码Source io/agentscope/core/model/ModelException.java:22–118

模型异常,表示执行过程中的错误。位于 io.agentscope.core.model 包,继承自 RuntimeException。核心成员包括 getModelName、getProvider、toString、ModelException。

Exception thrown when model operations fail. This exception provides a unified way to handle errors from different model providers.

构造器摘要Constructor Summary

构造器Constructor说明Description
public ModelException(String message)
创建ModelException 使用消息。
Creates a ModelException with a message.
public ModelException(String message, Throwable cause)
初始化 `ModelException` 实例。
Creates a ModelException with a message and cause.
public ModelException(String message, String modelName, String provider)
初始化 `ModelException` 实例。
Creates a ModelException with message and model information.
public ModelException(String message, Throwable cause, String modelName, String provider)
初始化 `ModelException` 实例。
Creates a ModelException with message, cause, and model information.

方法摘要Method Summary

方法Method说明Description
public String getModelName()
获取模型名称。
Gets the name of the model that caused the error.
public String getProvider()
获取提供者。
Gets the provider of the model that caused the error.
public String toString()
返回 `toString` 结果。
Returns the to string.

构造器详情Constructor Detail

ModelException

public ModelException(String message)

创建ModelException 使用消息。

Creates a ModelException with a message.

参数Parameters
名称Name类型Type说明Description
messageString错误消息。the error message
源码Source io/agentscope/core/model/ModelException.java:35–39

ModelException

public ModelException(String message, Throwable cause)

初始化 ModelException 实例。

Creates a ModelException with a message and cause.

参数Parameters
名称Name类型Type说明Description
messageString错误消息。the error message
causeThrowablecause(类型 `Throwable`)。the underlying cause of the exception
源码Source io/agentscope/core/model/ModelException.java:49–53

ModelException

public ModelException(String message, String modelName, String provider)

初始化 ModelException 实例。

Creates a ModelException with message and model information.

参数Parameters
名称Name类型Type说明Description
messageString错误消息。the error message
modelNameString模型名称(类型 `String`)。the name of the model that caused the error
providerString提供者(类型 `String`)。the provider of the model (e.g., "openai", "dashscope")
源码Source io/agentscope/core/model/ModelException.java:65–69

ModelException

public ModelException(String message, Throwable cause, String modelName, String provider)

初始化 ModelException 实例。

Creates a ModelException with message, cause, and model information.

参数Parameters
名称Name类型Type说明Description
messageString错误消息。the error message
causeThrowablecause(类型 `Throwable`)。the underlying cause of the exception
modelNameString模型名称(类型 `String`)。the name of the model that caused the error
providerString提供者(类型 `String`)。the provider of the model (e.g., "openai", "dashscope")
源码Source io/agentscope/core/model/ModelException.java:82–86

方法详情Method Detail

getModelName

public String getModelName()

获取模型名称。

Gets the name of the model that caused the error.

返回Returns String
返回字符串结果。the model name, or null if not set
源码Source io/agentscope/core/model/ModelException.java:93–95

getProvider

public String getProvider()

获取提供者。

Gets the provider of the model that caused the error.

返回Returns String
返回字符串结果。the provider name, or null if not set
源码Source io/agentscope/core/model/ModelException.java:102–104

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/model/ModelException.java:106–117
基于官方固定版本源码静态生成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.