Ensure mapping of Rust exceptions cover all cases.

This commit is contained in:
Benoit Marty 2024-09-12 13:05:45 +02:00 committed by Benoit Marty
parent f028e902db
commit e5fdfc366b
2 changed files with 16 additions and 8 deletions

View file

@ -14,6 +14,8 @@ import org.matrix.rustcomponents.sdk.RecoveryException as RustRecoveryException
fun Throwable.mapRecoveryException(): RecoveryException { fun Throwable.mapRecoveryException(): RecoveryException {
return when (this) { return when (this) {
is RustRecoveryException -> {
when (this) {
is RustRecoveryException.SecretStorage -> RecoveryException.SecretStorage( is RustRecoveryException.SecretStorage -> RecoveryException.SecretStorage(
message = errorMessage message = errorMessage
) )
@ -21,6 +23,8 @@ fun Throwable.mapRecoveryException(): RecoveryException {
is RustRecoveryException.Client -> RecoveryException.Client( is RustRecoveryException.Client -> RecoveryException.Client(
source.mapClientException() source.mapClientException()
) )
}
}
else -> RecoveryException.Client( else -> RecoveryException.Client(
ClientException.Other("Unknown error") ClientException.Other("Unknown error")
) )

View file

@ -12,7 +12,11 @@ import org.matrix.rustcomponents.sdk.ClientException as RustClientException
fun Throwable.mapClientException(): ClientException { fun Throwable.mapClientException(): ClientException {
return when (this) { return when (this) {
is RustClientException -> {
when (this) {
is RustClientException.Generic -> ClientException.Generic(msg) is RustClientException.Generic -> ClientException.Generic(msg)
}
}
else -> ClientException.Other(message ?: "Unknown error") else -> ClientException.Other(message ?: "Unknown error")
} }
} }