For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
JSONStore errors
Learn about JSONStore errors.
Possible JSONStore error codes that are returned are listed in JSONStore error codes.
JavaScript
JSONStore uses an error object to return messages about the cause of failures.
When an error occurs during a JSONStore operation (for example the find, and add methods in the JSONStoreInstance class) an error object is returned. It provides information about the cause of the failure.
Example
var errorObject = { src: 'find', // Operation that failed. err: -50, // Error code. msg: 'PERSISTENT_STORE_FAILURE', // Error message. col: 'people', // Collection name. usr: 'jsonstore', // User name. doc: {_id: 1, {name: 'carlos', age: 99}}, // Document that is related to the failure. res: {...} // Response from the server. }
Not all the key/value pairs are part of every error object. For example, the doc value is only available when the operation failed because of a document (for example the remove method in the JSONStoreInstance class) failed to remove a document.
Objective-C
All of the APIs that might fail take an error parameter that takes an address to an NSError object. If you don not want to be notified of errors, we can pass in nil. When an operation fails, the address is populated with an NSError, which has an error and some potential userInfo. The userInfo might contain extra details (for example, the document that caused the failure).
Example
// This NSError points to an error if one occurs. NSError* error = nil; // Perform the destroy. [JSONStore destroyDataAndReturnError:&error];
Java
All of the Java™ API calls throw a certain exception, depending on the error that happened. We can either handle each exception separately, or we can catch JSONStoreException as an umbrella for all JSONStore exceptions.
Example
try { WL.JSONStore.closeAll(); } catch(JSONStoreException e) { // Handle error condition. }
Parent topic: Troubleshooting JSONStore