Class DataAPIFaultyResponseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.datastax.astra.client.exception.DataApiException
com.datastax.astra.client.exception.DataAPIFaultyResponseException
- All Implemented Interfaces:
Serializable
Represents a specific kind of
DataApiException
that is thrown when the response
received from the Data API does not match the expected format or content. This exception
is typically thrown in situations where the API response is either malformed, incomplete,
or contains an error code indicating a failure that needs to be addressed by the client application.
This exception encapsulates details about the command that triggered the erroneous response and the actual response received from the Data API, allowing for more informed error handling and debugging. It is advisable to catch this exception specifically when performing operations that are critical and have known potential for response inconsistencies.
Example usage:
try {
ApiResponse response = dataApiClient.executeCommand(someCommand);
if (!response.isSuccessful()) {
throw new DataApiFaultyResponseException(someCommand, response, "The response indicates a failure.");
}
// Process the successful response
} catch (DataApiFaultyResponseException e) {
// Handle scenarios where the API response was not as expected
log.error("Faulty response received for command: " + e.getCommand() + " with message: " + e.getMessage(), e);
}
- See Also:
-
Field Summary
Fields inherited from class com.datastax.astra.client.exception.DataApiException
DEFAULT_ERROR_CODE, DEFAULT_ERROR_MESSAGE, ERROR_CODE_HTTP, ERROR_CODE_INTERRUPTED, ERROR_CODE_RANDOM, ERROR_CODE_SERIALIZATION, ERROR_CODE_TIMEOUT
-
Constructor Summary
ConstructorDescriptionDataAPIFaultyResponseException
(Command cmd, ApiResponse res, String msg) Constructs a new exception with the specified command that triggered the error, the API response received, and a custom error message. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
DataAPIFaultyResponseException
Constructs a new exception with the specified command that triggered the error, the API response received, and a custom error message.- Parameters:
cmd
- The command object that was executed and led to the faulty response.res
- The actual response received from the Data API which was not as expected.msg
- The detailed error message explaining the nature of the fault.
-