Class DataAPIResponseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.datastax.astra.client.exceptions.DataAPIException
com.datastax.astra.client.exceptions.DataAPIResponseException
- All Implemented Interfaces:
Serializable
Extends
DataAPIException
to specifically address errors encountered during the
processing of responses from the Data API. This exception is particularly useful when
a command issued to the API is internally divided into multiple sub-operations, each of
which might succeed or fail independently. It aggregates detailed information about each
sub-operation, including execution times and any errors encountered, facilitating comprehensive
error tracking and debugging.
The commandsList
attribute of this exception holds a collection of ExecutionInfos
objects, each representing the outcome of a sub-operation. This detailed breakdown helps in
identifying specific points of failure within a complex command execution sequence, making it
easier for developers to diagnose issues and implement more robust error handling and recovery
strategies.
Example usage:
try {
List<Document> longListOfDocuments;
collection.insertMany(longListOfDocuments);
} catch (DataApiResponseException e) {
e.getCommandsList().forEach(executionInfo -> {
if (executionInfo.hasErrors()) {
log.error("Error in sub-operation: " + executionInfo.getErrorDetails());
}
});
// Handle the exception or notify the user
}
- See Also:
-
Field Summary
Fields inherited from class com.datastax.astra.client.exceptions.DataAPIException
DEFAULT_ERROR_CODE, DEFAULT_ERROR_MESSAGE, ERROR_CODE_HTTP, ERROR_CODE_INTERRUPTED, ERROR_CODE_RANDOM, ERROR_CODE_SERIALIZATION, ERROR_CODE_TIMEOUT
-
Constructor Summary
ConstructorDescriptionDataAPIResponseException
(List<ExecutionInfos> cmdList) Constructor with list of constructors. -
Method Summary
Modifier and TypeMethodDescriptionFlattening errors as a list.static String
getErrorCode
(List<ExecutionInfos> commands) Parse the command list to get first error of first command.static String
getErrorMessage
(List<ExecutionInfos> commands) Parse the command list to get first error of first command.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
DataAPIResponseException
Constructor with list of constructors.- Parameters:
cmdList
- command execution list
-
-
Method Details
-
getApiErrors
Flattening errors as a list.- Returns:
- list of errors
-
getErrorMessage
Parse the command list to get first error of first command.- Parameters:
commands
- input command list- Returns:
- error message from the API
-
getErrorCode
Parse the command list to get first error of first command.- Parameters:
commands
- input command list- Returns:
- error code from the API
-