use of io.realm.mongodb.ErrorCode in project realm-java by realm.
the class SyncSession method notifySessionError.
// This callback will happen on the thread running the Sync Client.
void notifySessionError(String nativeErrorCategory, int nativeErrorCode, String errorMessage, String clientResetPathInfo) {
if (errorHandler == null) {
return;
}
ErrorCode errCode = ErrorCode.fromNativeError(nativeErrorCategory, nativeErrorCode);
if (errCode == ErrorCode.CLIENT_RESET) {
// errorMessage contains the path to the backed up file
if (clientResetPathInfo == null) {
throw new IllegalStateException("Missing Client Reset info.");
}
RealmConfiguration backupRealmConfiguration = configuration.forErrorRecovery(clientResetPathInfo);
if (clientResetHandler instanceof ManuallyRecoverUnsyncedChangesStrategy) {
((ManuallyRecoverUnsyncedChangesStrategy) clientResetHandler).onClientReset(this, new ClientResetRequiredError(appNativePointer, errCode, errorMessage, configuration, backupRealmConfiguration));
} else if (clientResetHandler instanceof DiscardUnsyncedChangesStrategy) {
((DiscardUnsyncedChangesStrategy) clientResetHandler).onError(this, new ClientResetRequiredError(appNativePointer, errCode, errorMessage, configuration, backupRealmConfiguration));
}
} else {
AppException wrappedError;
if (errCode == ErrorCode.UNKNOWN) {
wrappedError = new AppException(nativeErrorCategory, nativeErrorCode, errorMessage);
} else {
wrappedError = new AppException(errCode, errorMessage);
}
errorHandler.onError(this, wrappedError);
}
}
use of io.realm.mongodb.ErrorCode in project realm-java by realm.
the class NetworkRequest method onError.
/**
* Request failed. Will be called by the ObjectStore completion handler.
*/
// Called by JNI
@SuppressWarnings("unused")
@Override
public void onError(String nativeErrorCategory, int nativeErrorCode, String errorMessage) {
ErrorCode code = ErrorCode.fromNativeError(nativeErrorCategory, nativeErrorCode);
if (code == ErrorCode.UNKNOWN) {
// In case of UNKNOWN errors parse as much error information on as possible.
String detailedErrorMessage = String.format("{%s::%s} %s", nativeErrorCategory, nativeErrorCode, errorMessage);
error.set(new AppException(code, detailedErrorMessage));
} else {
error.set(new AppException(code, errorMessage));
}
latch.countDown();
}
Aggregations