Exception and Error Handling

RFID SDK for Android 2.0.2.124

Overview

This guides provides details about exception and error handling using RFID3 API

Details

The Zebra RFID Android SDK throws two types of exceptions as a given

  1. InvalidUsageException
  2. This exception is thrown when the user passes an invalid parameter, calling getInfo() gives detail error message

  3. OperationFailureException:
  4. This exception is thrown when the requested operation is failed. The Exception contains the Operation RFIDResults, status description, time stamp & vendor specific message for the operation failure

Exception Handling

All API should be called under try-catch block to catch the exception thrown while performing API by SDK. Following example also shows how to get details about further error details and descriptions. OperationFailureException has getVendorMessage() and getResults() methods. While InvalidUsageException has getVendorMessage() and getInfo() methods


try {
    reader.connect();
} catch (InvalidUsageException e) {
    e.printStackTrace();
    Log.d("DEMO", "InvalidUsageException=" + e.getVendorMessage() + " " + e.getInfo());
} catch (OperationFailureException e) {
    e.printStackTrace();
    Log.d("DEMO", "InvalidUsageException=" + e.getVendorMessage() + " " + e.getResults());
}

For details about various error codes please refer java docs RFIDResults