public static interface SyncSession.ErrorHandler
SyncManager#setDefaultSessionErrorHandler(ErrorHandler)
,
SyncConfiguration.Builder#errorHandler(ErrorHandler)
Modifier and Type | Method and Description |
---|---|
void |
onError(SyncSession session,
ObjectServerError error)
Callback for errors on a session object.
|
void onError(SyncSession session, ObjectServerError error)
When the error.getErrorCode()
returns ErrorCode.CLIENT_RESET
, it indicates the Realm
needs to be reset and the error
can be cast to ClientResetRequiredError
.
A synced Realm may need to be reset because the Realm Object Server encountered an error and had to be restored from a backup. If the backup copy of the remote Realm is of an earlier version than the local copy of the Realm, the server will ask the client to reset the Realm.
The reset process is as follows: the local copy of the Realm is copied into a recovery directory for safekeeping, and then deleted from the original location. The next time the Realm for that URL is opened, the Realm will automatically be re-downloaded from the Realm Object Server, and can be used as normal.
Data written to the Realm after the local copy of the Realm diverged from the backup remote copy will be present in the local recovery copy of the Realm file. The re-downloaded Realm will initially contain only the data present at the time the Realm was backed up on the server.
The client reset process can be initiated in one of two ways:
ClientResetRequiredError.executeClientReset()
manually. All Realm instances must be
closed before this method is called.
session
- SyncSession
this error happened on.error
- type of error.