Handle 'invalid server' error in server selection screen properly. (#214)

* Handle 'invalid server' error in server selection screen properly.

* Use `action_learn_more` for composing the server location footer action.
This commit is contained in:
Jorge Martin Espinosa 2023-03-21 09:34:14 +01:00 committed by GitHub
parent 93a77d94c1
commit 2906168baa
24 changed files with 132 additions and 127 deletions

View file

@ -36,13 +36,13 @@ sealed interface Async<out T> {
}
}
suspend fun <T> (suspend () -> T).execute(state: MutableState<Async<T>>) {
suspend fun <T> (suspend () -> T).execute(state: MutableState<Async<T>>, errorMapping: ((Throwable) -> Throwable)? = null) {
try {
state.value = Async.Loading()
val result = this()
state.value = Async.Success(result)
} catch (error: Throwable) {
state.value = Async.Failure(error)
state.value = Async.Failure(errorMapping?.invoke(error) ?: error)
}
}