Improve error mapping
This commit is contained in:
parent
e12726f405
commit
98792c9562
4 changed files with 16 additions and 6 deletions
|
|
@ -19,7 +19,7 @@ fun Throwable.mapAuthenticationException(): AuthenticationException {
|
|||
is ClientBuildException.InvalidServerName -> AuthenticationException.InvalidServerName(message)
|
||||
is ClientBuildException.SlidingSyncVersion -> AuthenticationException.SlidingSyncVersion(message)
|
||||
is ClientBuildException.Sdk -> AuthenticationException.Generic(message)
|
||||
is ClientBuildException.ServerUnreachable -> AuthenticationException.Generic(message)
|
||||
is ClientBuildException.ServerUnreachable -> AuthenticationException.ServerUnreachable(message)
|
||||
is ClientBuildException.SlidingSync -> AuthenticationException.Generic(message)
|
||||
is ClientBuildException.WellKnownDeserializationException -> AuthenticationException.Generic(message)
|
||||
is ClientBuildException.WellKnownLookupFailed -> AuthenticationException.Generic(message)
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import org.matrix.rustcomponents.sdk.OidcException
|
|||
|
||||
class AuthenticationExceptionMappingTest {
|
||||
@Test
|
||||
fun `mapping an exception with no message returns 'Unknown error' message`() {
|
||||
fun `mapping an exception with no message returns null message`() {
|
||||
val exception = Exception()
|
||||
val mappedException = exception.mapAuthenticationException()
|
||||
assertThat(mappedException.message).isEqualTo("Unknown error")
|
||||
assertThat(mappedException.message).isEqualTo(null)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -46,7 +46,7 @@ class AuthenticationExceptionMappingTest {
|
|||
assertThat(ClientBuildException.Sdk("SDK issue").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Generic>("SDK issue")
|
||||
assertThat(ClientBuildException.ServerUnreachable("Server unreachable").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Generic>("Server unreachable")
|
||||
.isException<AuthenticationException.ServerUnreachable>("Server unreachable")
|
||||
assertThat(ClientBuildException.SlidingSync("Sliding Sync").mapAuthenticationException())
|
||||
.isException<AuthenticationException.Generic>("Sliding Sync")
|
||||
assertThat(ClientBuildException.WellKnownDeserializationException("WellKnown Deserialization").mapAuthenticationException())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue