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

Add specific exception for auth errors being sent to to the Sync Session error handler

Open cmelchior opened this issue 1 year ago • 1 comments

Closes #1640

This adds a specific exception class for auth errors being sent to the SyncSession error handler. This is relevant as this indicates the user's credentials are no longer valid and they need to log in again.

Some open questions:

  • [ ] Should it be possible to update the refresh token on an already open Realm? (this will require changes in Core)
  • [ ] It is a bit annoying to create an "auth" type exception under SyncException when we already have AuthException under AppException. But relaxing the interface would be a breaking change and besides, this is the only "App" type exception that would surface here anyway.
  • [ ] Naming... alternatives considered: SyncSessionExpiredException, SyncAuthException, SyncSessionAuthExpired. Choosing AuthExpiredException was somewhat arbitrary, except it felt short and to the point. Not sure if Sync or Session should somehow be part of the name to separate it more from the generic AuthException that is an AppException. All our other specific exception types end with Exception

cmelchior avatar Jan 29 '24 08:01 cmelchior

@nirinchev believes that Core would automatically trigger a reconnect if you log the same user back in again. If this happens, users do not need to close the Realm. We need to test the behaviour.

cmelchior avatar Jan 29 '24 10:01 cmelchior