Class DataApiException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.datastax.astra.client.exception.DataApiException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AuthenticationException, DataAPIFaultyResponseException, DataApiResponseException

public class DataApiException extends RuntimeException
Represents a runtime exception that occurs within the Data API client. This exception is thrown to indicate a problem encountered while performing operations such as querying, updating, or deleting data through the Data API. It acts as a wrapper for lower-level exceptions to provide a more general fault indication to the client code.

This exception should be caught and handled by the client application to gracefully manage API-related errors, such as connectivity issues, data format mismatches, or unauthorized access attempts. It is recommended to log the details of this exception and present a user-friendly message to the end-user, if applicable.

Example usage:

 
 try {
     collection.insertOne(document);
 } catch (DataApiException e) {
     // Handle the exception, e.g., log it or display an error message
     log.error("Error performing Data API operation: " + e.getMessage(), e);
 }
 
 
See Also:
  • Field Details

  • Constructor Details

    • DataApiException

      public DataApiException(String errorCode, String errorMessage)
      Constructors providing all arguments and a parent exception.
      Parameters:
      errorCode - error code
      errorMessage - error message
    • DataApiException

      public DataApiException(String errorMessage, String errorCode, Throwable parent)
      Constructors providing all arguments and a parent exception.
      Parameters:
      errorMessage - error message
      errorCode - error code
      parent - parent exception