Class DifyApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.agentscope.core.rag.integration.dify.exception.DifyApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DifyAuthException
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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDifyApiException(int statusCode, String message) Creates a new DifyApiException with HTTP status code.DifyApiException(int statusCode, String errorCode, String message) Creates a new DifyApiException with full error details.DifyApiException(int statusCode, String errorCode, String message, Throwable cause) Creates a new DifyApiException with full error details and cause.DifyApiException(String message) Creates a new DifyApiException with a message.DifyApiException(String message, Throwable cause) Creates a new DifyApiException with a message and cause. -
Method Summary
Modifier and TypeMethodDescriptionGets the Dify error code.intGets the HTTP status code.booleanChecks if this is a client error (4xx status code).booleanChecks if this is a rate limit error (429 status code).booleanChecks if this is a server error (5xx status code).toString()Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
DifyApiException
Creates a new DifyApiException with a message.- Parameters:
message- the error message
-
DifyApiException
Creates a new DifyApiException with a message and cause.- Parameters:
message- the error messagecause- the underlying cause
-
DifyApiException
Creates a new DifyApiException with HTTP status code.- Parameters:
statusCode- the HTTP status codemessage- the error message
-
DifyApiException
Creates a new DifyApiException with full error details.- Parameters:
statusCode- the HTTP status codeerrorCode- the Dify error codemessage- the error message
-
DifyApiException
Creates a new DifyApiException with full error details and cause.- Parameters:
statusCode- the HTTP status codeerrorCode- the Dify error codemessage- the error messagecause- the underlying cause
-
-
Method Details
-
getStatusCode
public int getStatusCode()Gets the HTTP status code.- Returns:
- the status code, or -1 if not available
-
getErrorCode
Gets the Dify error code.- Returns:
- the error code, or null if not available
-
isClientError
public boolean isClientError()Checks if this is a client error (4xx status code).- Returns:
- true if status code is 4xx
-
isServerError
public boolean isServerError()Checks if this is a server error (5xx status code).- Returns:
- true if status code is 5xx
-
isRateLimitError
public boolean isRateLimitError()Checks if this is a rate limit error (429 status code).- Returns:
- true if status code is 429
-
toString
-