Skip to content

Appendix

Error Handling

Errors are reported either through error or failure handlers. Error object is passed as an argument to the error handler. All the APIs accept success and failure handlers.

A developer can query for error codes, error description, userInfo, and so on. Error object format for each language is as follows. For Offline Objects error codes, refer to the Error Codes section.

Language Error Handling
JavaScript Signature: function onFailure(error) Error object : JSObject Error code : error.code of type number. Error description : error.message of type string. Error domain: error.domain of type string, denotes the error domain. Error callstack: error.callStack of type string. Sample Code var sdk=new voltmx.sdk();var options={};function onSuccess() { alert("Application setup successful"); } function onFailure(error) { voltmx.print("Error Code: " + error.code); voltmx.print("Error Domain: " + error.domain); voltmx.print("Error Message: " + error.message); voltmx.print("Error Callstack:" + error.callStack); } sdk.getCurrentInstance().OfflineObjects.setup(options, onSuccess, onFailure);
Java Signature: public void onFailure(error) Error object : OfflineObjectsException Error code : (OfflineObjectsException)error.getErrorCode() of type int. Error description : (OfflineObjectsException)error.getMessage() of type string. Error domain : (OfflineObjectsException)error.getDomain() of type string Error callstack : (OfflineObjectsException)error.getCallStack() of type string. Sample Code VoltMXClient sdk= new VoltMXClient();OfflineObjects appSync = sdk.getOfflineObjects(); HashMap options=new HashMap(); appSync.setup(options, new VMXCallback() { @Override public void onSuccess(Object object) { Log.d("Application", "Application setup successful"); } @Override public void onFailure(Object error) { OfflineObjectsException e = (OfflineObjectsException)error; Log.d("Application", "Error Code:" + e.getErrorCode()); Log.d("Application", "Error Domain:" + e.getDomain()); Log.d("Application", "Error Message:" + e.getMessage()); Log.d("Application", "Error Callstack:" + e.getCallStack()); } });
Objective C Signature: onFailure:^(id error) Error object : Error Object Error code : error.code of type NSInteger. Error description : [error.userInfo localizedDescription] of type NSString. Error domain : error.domain of type string Error callstack : [error.userInfo callStack] of type string. Sample Code VMXClient *sdk= [VMXClient sharedClient]; OfflineObjects *applicationSync = [sdk getOfflineObjects];NSDictionary *options=@{};[applicationSync setup:options             onSuccess:onSuccess              onFailure:onFailure];   VMXSuccessCompletionHandler onSuccess = ^void(id error){     NSLog(@"Application setup successful"); };     VMXFailureCompletionHandler onFailure = ^void(id object){     OfflineObjectsError *error = (OfflineObjectsError)object;     NSLog(@"Error code: %@" error.code);     NSLog(@"Error domain: %@" error.domain);     NSLog(@"Error message: %@" [error.userInfo  localizedDescription]);     NSLog(@"Error Callstack:%@",[error.userInfo callStack]); }

Sync Errors

Sync operations performed on an object or object service report the sync errors back to the application developer through success and failure callbacks. Sync errors convey why certain records failed to sync with the backend. Sync errors carry backend assigned error codes and messages.

In a session, if a subset of records fails to sync with the backend, the sync errors are reported through success callback because this scenario is considered as sync partial success scenario.

If all records of a sync session fail to sync with the backend, the sync errors are reported through failure callback because this scenario is considered as a sync complete failure scenario.

Sync errors can be accessed using syncErrors key and are segregated as upload and download errors. These convey errors occurred as part of upload and download phases and are accessed using the upload and download keys on syncErrors object. The sample sync errors containing both upload and download errors from response JSON are as follows:

{
  "syncErrors": {
    "upload": [
      {
        "opstatus": 20006,
        "object": "VTI_SAMPLE_ORDER",
        "primaryKeys": {
          "ORDER_NUMBER": "19"
        },
        "errmsg": "Invalid packed numeric format: TOTAL_VALUE check this once",
        "objectService": "SAPObjectService"
      },
      {
        "opstatus": 20006,
        "object": "VTI_SAMPLE_ORDER",
        "primaryKeys": {
          "ORDER_NUMBER": "20"
        },
        "errmsg": "Invalid packed numeric format: TOTAL_VALUE check this once",
        "objectService": "SAPObjectService"
      },
      {
        "opstatus": 20010,
        "object": "VTI_SAMPLE_ORDER",
        "primaryKeys": {
          "ORDER_NUMBER": "7184"
        },
        "errmsg": "unable to perform update on VTI_SAMPLE_ORDER",
        "objectService": "SAPObjectService"
      }
    ],
    "download": [
      {
        "opstatus": 20014,
        "object": "VTI_SAMPLE_ORDER",
        "errmsg": "unable to get from backend",
        "objectService": "SAPObjectService"
      },
      {
        "opstatus": 20014,
        "object": "VTI_SAMPLE_ORDER_ITEM",
        "errmsg": "Object Source Mapping for VTI_SAMPLE_PRODUCT not found in object definition",
        "objectService": "SAPObjectService"
      }
    ]
  }
}

All the records in the sync errors carry the following information:

"primaryKeys"   – Primary keys of the current record
"object"     - Name of the entity or object this record belongs to
"objectService" – Name of the object service this object belongs to
"opstatus"   – Error code reported from the backend data system
"errmsg"     - Error message reported from the backend data system

Sample code to retrieve sync errors from success or failure callbacks.

Language Sync Errors
JavaScript var object = new voltmx.sdk.VMXObj("CATEGORY"); function onSuccess(data){ if(data.syncErrors) { alert("sync errors for given object sync operation is" + JSON.stringify(data.syncErrors)); } else { alert("Object level sync operation is success" + JSON.stringify(data)); } } function onFailure(error){ if(error.syncErrors) { alert("Object level sync failed with sync errors" + JSON.stringify(error.syncErrors)); } else { alert("Object level sync failed"+JSON.stringify(error)); } } var options = {}; object.startSync(options, onSuccess, onFailure, null);
Java syncObject = new VMXObj("CATEGORY");HashMapoptions=new HashMap();syncObject.startSync(options, new VMXCallback() { @Override public void onSuccess(Object object) { HashMap successObject = (HashMap) object; if(successObject.containsKey("syncErrors")) { Log.d("Object sync", "Object Sync is partial Success for syncObject with sync errors " + successObject.get("syncErrors")); } else { Log.d("Object sync", "Object Sync Successful for syncObject" + successObject); } } @Override public void onFailure(Object object) { OfflineObjectsException e= (OfflineObjectsException) object; List syncErrors = e.getSyncErrors(); if(syncErrors != null &;&; syncErrors.size> 0) { Log.d("Object sync", "Object Sync is unsuccessful for syncObject with sync errors " + syncErrors); } else { Log.d("Object Sync", "Object Sync unsuccessful for syncObject with Error :" + e); } } }, null);
Objective C VMXObj *object = [[VMXObj alloc] initWithName:objectName error:&error];NSDictionary *options=@{};[object startSync:options onSuccess:^(id object){ if([object objectForKey:@"syncErrors"]) { NSLog(@"Sync is partially successful for %@ Object! with sync errors", name, [object objectForKey:@"syncErrors"]); } else { NSLog(@"Sync successful for %@ Object!", name); } } onFailure:^(id object){ OfflineObjectsError *error = (OfflineObjectsError *)object; NSArray *syncErrors = [[error userInfo] objectForKey:@"syncErrors"]; if(syncErrors) { NSLog(@"Sync is complete failure for %@ Object! with sync errors", name, syncErrors); } else { NSLog(@"Error: Sync unsuccessful because of error:%@", [syncError description]); } } onProgress:nil];

Error Codes

Error codes and the associated messages from the Offline Objects feature are as follows. An error message will also contain the root cause details (error details).

Error Code Error Messages   Description
2000 An error occurred in the database layer: SQLite errors other than query execution errors.
2001 An error occurred while executing select query:  
2002 An error occurred while executing a SQL transaction with no rollback on error enabled:  
2003 An error occurred while executing a SQL transaction with rollback on error enabled:  
2004 Failed to encrypt database:  
2005 Error copying SQLCipher asset files to device:  
2006 Failed to open or create database:  
2007 Failed to load the SQLCipher libraries:  
2008 Failed to find and load the supported assets for SQLite database encryption:  
2009 An error occurred while upgrading the database schema:  
2010 Invalid database schema version found, cannot upgrade the database schema.  
2030 An error occurred in the network layer:  
2031 Network call failed due to connection timeout:  
2032 Network call failed due to socket connection timeout:  
2033 Network call failed due to security related issues:  
2034 Unable to connect to host:  
2035 Host not found:  
2036 No active internet connectivity found:  
2037 Network response is either null or invalid JSON:  
2038 Server responded with error opstatus:  
2039 The URL used is invalid:  
2043 HTTP message integrity check failed.  
2300 An error occurred in the ORM operation: CRUD operation errors.
2301 No record found in the database for given columns values or where condition:  
2302 Foreign key constraint violation error:  
2303 Updating values for primary key(s) of a record is not allowed: Update operation doesn’t support updating values for primary keys.
2304 Supplied options are invalid, common causes are incorrect property name or value or data types: Verify record provided to the CRUD operations for invalid column names or data types.
2305 Primary key values cannot be null or empty:  
2306 Property or column names cannot be null or empty in orderByMap option:  
2307 Cannot perform ORM operations on null or empty record:  
2308 Mandatory field or property missing in the ORM input: Invalid inputs to CRUD operations.
2309 Value should not be sent for auto generated columns: Don’t supply values for primary keys that are marked as auto generated in a Create operation.
2310 Invalid field or property found in the ORM input: Invalid property or column name in the supplied input to CRUD operations.
2311 ORM input is of invalid data type or length:  
2330 Setup failed with an error:  
2331 Schema setup failed with an error:  
2332 Metadata refresh failed with an error:  
2333 Object metadata not found for the given offline object: Ensure that input contains valid object or object service name or object properties.
2334 Namespace metadata not found for the given offline object: Ensure that input contains valid object or object service name or object properties.
2335 Root metadata not found for the given offline object: Ensure that input contains valid object or object service name or object properties.
2336 Error parsing object attributes in object metadata: Ensure that input contains valid object or object service name or object properties.
2337 Error parsing object metadata:  
2338 Error parsing relationships:  
2339 Error parsing Offline Objects metadata:  
2340 Invalid root metadata found for the given object service: Ensure that input contains valid object or object service name or object properties.
2341 Metadata JSON from server does not contain TIMESTAMP key:  
2342 Invalid Metadata JSON string form: EM_INVALID_METADATA_JSON  
2343 An error occurred while creating tables during setup:  
2344 Namespace cannot be null or empty in the metadata:  
2345 Metadata JSON from server does not contain OBJECTS key:  
2346 Invalid relationship type found. Supported types are 'One To Many', 'Many To One' and 'One To One':  
2347 Metadata url is null/empty:  
2348 Cannot generate initial indices:  
2349 Metadata attributes cannot be null/empty:  
2350 Attribute operations cannot be null /empty:  
2351 Unable to serialize delta context value:  
2352 Unable to serialize:  
2400 Cannot create Offline Object with name as null or empty string:  
2401 Cannot create Offline Object Service with name as null or empty string:  
2403 Unable to parse namespace metadata:  
2404 SDK Object name cannot be null/empty:  
2405 No delta context found while creating download request for the given object service:  
2406 Invalid object service name:  
2407 MetaInfo table does not exist:  
2408 An error occurred while inserting into metaInfo table:  
2409 Attribute name cannot be null/empty:  
2411 An error occurred while performing ORM operation on metaInfo table:  
2412 Metadata is null/empty for object service:  
2430 An error occurred while dropping the database:  
2460 An error has occurred in the sync layer:  
2461 Sync is currently in progress for this object or object service:  
2462 Object Service url cannot be null/empty:  
2463 Object url cannot be null/empty:  
2464 Object Service version cannot be null/empty:  
2465 Invalid record action:  
2466 No relationship between the given Offline Objects:  
2467 The number of source attributes and target attributes are not same in the given relationship:  
2468 More than one parent was found for a given child record:  
2469 Unable to build hierarchical upload payload for the given set of records even after maximum iterations:  
2470 An error occurred while parsing JSON:  
2471 An error occurred while trying to perform rollback:  
2472 Filters applied to the current sync operation are invalid:  
2473 Sync upload failed with an error:  
2474 Sync download failed with an error:  
2475 Database encryption passphrase must be of type string: Ensure that encryption passphrase is a string and contains at least 6 characters.
2476 Pending sync requests failed with an error. This error is triggered when the applications cached upload requests fail.
2478 Syncing operation has been cancelled. This error code is triggered when an in-progress Syncing operation is successfully cancelled. With reference to .cancelSync and .cancelSync code samples, the onFailure callback is triggered for startSync operation, and the error object displays this error code.
2479 Sync cancellation failed. This error code is triggered when an attempt to cancel an inprogress syncing operation fails. This operation fails if the syncing operation is already completed, or not started at all. With reference to .cancelSync and .cancelSync code samples, the onFailure callback is triggered for cancelSync operation, and the error object displays this error code.
2480 An error occurred while trying to clear offline data on object service: : This error is triggered when the application is unable to clear the offline data at that particular moment. During failure, all the changes will be rolled back to the existing state. If the .clearOfflineData API is triggered while some other operation (for example, startSync), is in progress, the database can get corrupted.
2481 An error occurred while trying to fetch the pending Sync records:  
2482 Application Sync options provided are invalid Options provided for application sync are invalid.
2483 Setup is not performed. There are no object services to sync: The Offline Objects setup is not done. Therefore, no Object Service could be synced.
2560 An error occurred while performing an operation on binary data: Generic binary download error.
2561 Binary column is expected, supplied column is not of type binary: . Verify if the column name provided in options is a valid number.
2562 Chunk size supplied is not a valid number: Verify if the chunk size provided in the options is a valid number.
2563 Failed to save the downloaded file path in the device database: File is downloaded from the server on to the client, but failed to persist the file path in the app database.
2564 Binary download failed: Failed to download binary from the server.
2565 Query type sent is not a valid value: The query type sent in the getBinaryStatus API is invalid.
2566 Invalid options sent to binary status: Options provided to getBinaryStatus API are invalid.
2913 Upload cache has duplicate cache entry for same sync object. This error is triggered when the application has duplicate cached upload requests and goes to an unrecoverable state.