realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

Expose error codes in the different realm exceptions

Open clementetb opened this issue 2 years ago • 3 comments

Problem

The user has no access to the error code property in app exceptions, if they like to react to a specific error code they have to do string matching.

Solution

Expose the error code as a public property.

Alternatives

No response

How important is this improvement for you?

Would be a major improvement

Feature would mainly be used with

Atlas Device Sync

clementetb avatar Jun 08 '23 11:06 clementetb

We tried to solve this through the Exception type hierarchy. This could point to us needing to extend this hierarchy.

What was the exact use case that caused this?

cmelchior avatar Jun 08 '23 11:06 cmelchior

I was trying to automatically register a user when logging in. The thing is that I tried to register and then log in, doing it the other way around (logging in and then registering) solves the issue because we have an exception to catch when a user does not exist. So there is no need to extend the hierarchy.

clementetb avatar Jun 12 '23 08:06 clementetb

After discussion, we need to verify this check actually works:

                ErrorCode.RLM_ERR_ACCOUNT_NAME_IN_USE -> {
                    UserAlreadyExistsException(msg)
                }

cmelchior avatar Jun 12 '23 09:06 cmelchior