Class DataAPIFaultyResponseException

All Implemented Interfaces:
Serializable

public class DataAPIFaultyResponseException extends DataApiException
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:
  • Constructor Details

    • DataAPIFaultyResponseException

      public DataAPIFaultyResponseException(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.
      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.