Improve error mapping

This commit is contained in:
Benoit Marty 2025-11-07 09:52:04 +01:00
parent b61ce1b19c
commit e12726f405
6 changed files with 16 additions and 24 deletions

View file

@ -7,10 +7,13 @@
package io.element.android.libraries.matrix.api.auth
sealed class AuthenticationException(message: String) : Exception(message) {
class AccountAlreadyLoggedIn(userId: String) : AuthenticationException(userId)
class InvalidServerName(message: String) : AuthenticationException(message)
class SlidingSyncVersion(message: String) : AuthenticationException(message)
class Oidc(message: String) : AuthenticationException(message)
class Generic(message: String) : AuthenticationException(message)
sealed class AuthenticationException(message: String?) : Exception(message) {
data class AccountAlreadyLoggedIn(
val userId: String,
) : AuthenticationException(null)
class InvalidServerName(message: String?) : AuthenticationException(message)
class SlidingSyncVersion(message: String?) : AuthenticationException(message)
class Oidc(message: String?) : AuthenticationException(message)
class Generic(message: String?) : AuthenticationException(message)
}

View file

@ -12,7 +12,6 @@ import org.matrix.rustcomponents.sdk.ClientBuildException
import org.matrix.rustcomponents.sdk.OidcException
fun Throwable.mapAuthenticationException(): AuthenticationException {
val message = this.message ?: "Unknown error"
return when (this) {
is AuthenticationException -> this
is ClientBuildException -> when (this) {