DifyApiException
public class DifyApiException extends RuntimeException
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:34–158Dify API 异常,表示执行过程中的错误。位于 io.agentscope.core.rag.integration.dify.exception 包,继承自 RuntimeException。核心成员包括 getStatusCode、getErrorCode、isClientError、isServerError、isRateLimitError、toString。
Exception thrown when Dify API returns an error response.
This exception encapsulates error information from Dify API responses, including HTTP status codes, error codes, and error messages.
Common error scenarios:
-
400 Bad Request: Invalid parameters or malformed request
-
401 Unauthorized: Invalid or missing API key
-
403 Forbidden: Insufficient permissions
-
404 Not Found: Dataset or document not found
-
429 Too Many Requests: Rate limit exceeded
-
500 Internal Server Error: Dify service error
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public DifyApiException(String message) | 创建新的DifyApiException 使用消息。 Creates a new DifyApiException with a message. |
public DifyApiException(String message, Throwable cause) | 初始化 `DifyApiException` 实例。 Creates a new DifyApiException with a message and cause. |
public DifyApiException(int statusCode, String message) | 初始化 `DifyApiException` 实例。 Creates a new DifyApiException with HTTP status code. |
public DifyApiException(int statusCode, String errorCode, String message) | 初始化 `DifyApiException` 实例。 Creates a new DifyApiException with full error details. |
public DifyApiException(int statusCode, String errorCode, String message, Throwable cause) | 初始化 `DifyApiException` 实例。 Creates a new DifyApiException with full error details and cause. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public int getStatusCode() | 获取 `getStatusCode`。 Gets the HTTP status code. |
public String getErrorCode() | 获取 `getErrorCode`。 Gets the Dify error code. |
public boolean isClientError() | 判断是否客户端错误。 Checks if this is a client error (4xx status code). |
public boolean isServerError() | 判断是否服务端错误。 Checks if this is a server error (5xx status code). |
public boolean isRateLimitError() | 判断是否速率限制错误。 Checks if this is a rate limit error (429 status code). |
public String toString() | 返回 `toString` 结果。 Returns the to string. |
构造器详情Constructor Detail
DifyApiException
public DifyApiException(String message)
创建新的DifyApiException 使用消息。
Creates a new DifyApiException with a message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 错误消息。the error message |
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:44–48DifyApiException
public DifyApiException(String message, Throwable cause)
初始化 DifyApiException 实例。
Creates a new DifyApiException with a message and cause.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | String | 错误消息。the error message |
cause | Throwable | cause(类型 `Throwable`)。the underlying cause |
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:56–60DifyApiException
public DifyApiException(int statusCode, String message)
初始化 DifyApiException 实例。
Creates a new DifyApiException with HTTP status code.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
statusCode | int | 状态 Code(类型 `int`)。the HTTP status code |
message | String | 错误消息。the error message |
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:68–72DifyApiException
public DifyApiException(int statusCode, String errorCode, String message)
初始化 DifyApiException 实例。
Creates a new DifyApiException with full error details.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
statusCode | int | 状态 Code(类型 `int`)。the HTTP status code |
errorCode | String | 错误 Code(类型 `String`)。the Dify error code |
message | String | 错误消息。the error message |
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:81–85DifyApiException
public DifyApiException(int statusCode, String errorCode, String message, Throwable cause)
初始化 DifyApiException 实例。
Creates a new DifyApiException with full error details and cause.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
statusCode | int | 状态 Code(类型 `int`)。the HTTP status code |
errorCode | String | 错误 Code(类型 `String`)。the Dify error code |
message | String | 错误消息。the error message |
cause | Throwable | cause(类型 `Throwable`)。the underlying cause |
io/agentscope/core/rag/integration/dify/exception/DifyApiException.java:95–99方法详情Method Detail
getStatusCode
public int getStatusCode()
获取 getStatusCode。
Gets the HTTP status code.
intio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:106–108getErrorCode
public String getErrorCode()
获取 getErrorCode。
Gets the Dify error code.
Stringio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:115–117isClientError
public boolean isClientError()
判断是否客户端错误。
Checks if this is a client error (4xx status code).
booleanio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:124–126isServerError
public boolean isServerError()
判断是否服务端错误。
Checks if this is a server error (5xx status code).
booleanio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:133–135isRateLimitError
public boolean isRateLimitError()
判断是否速率限制错误。
Checks if this is a rate limit error (429 status code).
booleanio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:142–144toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/rag/integration/dify/exception/DifyApiException.java:146–157