Thanks for the reply.
We are designing an offline-first application based on realm-sync. And to keep users’ data law-abiding and up to date, we should care about proper sync-error handling. Moreover, we should also take care of users’ data when they are offline thus, taking care of proper realm error handling. For instance, let’s consider two sync session errors.
- ErrorBadClientFileIdent - This error occurs when the client is using a realm file that the server cannot access after terminating and re-enabling Sync. To recover from this error and to not lose data, the user should perform a client reset.
This kind of exception should be handled (The user should be aware of possible data loss and do a client reset).
- ErrorIllegalRealmPath - This error indicates that the client attempted to open a realm with a partition value of the wrong type. For example, you might see the error message “attempted to bind on illegal realm partition: expected partition to have type objectId but found the string”.To recover from this error, ensure that the type of the partition value used to open the realm matches the partition key type in your Sync configuration.
This kind of exception is a developer error. It should not be handled and when the exception emits that means the developer made issues while designing the app and should review the code and fix issues.
In general, I’d like to know which exceptions should I show to users and which ones not?. Is there any strategy to prevent data loss when the synchronization somehow fails?
Now related to the questions above:
- As I understood correctly the session errors are related to the cloud realm synchronization. The realm errors are related to the local database and emit when managing it (read/write). Please correct me if I’m wrong.
- No. I’m looking for recovery strategies for those exceptions which are crucial for the user’s data and, they should be aware of that issues.
- Not exactly, but I would always be happy to see more specific documentation with samples.