-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RLM_ERR_UNSUPPORTED_FILE_FORMAT_VERSION should throw a specific exception, not just IllegalStateException #1761
Comments
➤ PM Bot commented: Jira ticket: RKOTLIN-1090 |
Currently there is not elegant way to detect it. We could expose this Realm Core function. |
Why can't we detect it? As far as I can tell, we have an error code for it: https://github.com/realm/realm-core/blob/3648014ffdcaf6f570de78e1cb4572300c217975/src/realm/error_codes.h#L51 So it should be a matter of switching on the error code and throwing a more concrete exception. |
This would be the way to go IMHO. You can still use IllegalStateException if you just create a subclass that represents this specific error. |
Problem
I have an app that is using local realms. It does happen that users take a break from the app and then come back. When dropping support for pre Realm 5.0.0 files, those users are out of luck. I know you can't bring backwards compatibility back, but right now it is not possible to detect that this error has happened on the Kotlin client whereas on iOS realm throws a specific error (Realm.Error.unsupportedFileFormatVersion) that at least allows developers to catch the error and provide a way for the user to reach out to support (or send the file to a server to convert it as suggested by @nirinchev in another github issue).
Solution
Right now this is all I can do is to check if we get an IllegalStateException then inspect the message to see if it is an unsupported file format version error. This is NOT something that should have to go into production code IMHO.
Does the current API let me detect this in any other way? Is it safe to use this hack? Or are my returning customers screwed?
Alternatives
No response
How important is this improvement for you?
Dealbreaker
Feature would mainly be used with
Local Database only
The text was updated successfully, but these errors were encountered: