Cancelling coroutines operations such as authentication no longer displays an errors as it's something intentional

This commit is contained in:
Abdelilah El Aissaoui 2023-04-04 18:37:49 +02:00
parent 3b248f10eb
commit a920e2bb9e
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -78,7 +78,9 @@ class TabState @Inject constructor(
refreshEvenIfCrashesInteractiveResult = refreshEvenIfCrashesInteractive?.invoke(ex) ?: false refreshEvenIfCrashesInteractiveResult = refreshEvenIfCrashesInteractive?.invoke(ex) ?: false
if (showError) val containsCancellation = exceptionContainsCancellation(ex)
if (showError && !containsCancellation)
errorsManager.addError(newErrorNow(ex, ex.message.orEmpty())) errorsManager.addError(newErrorNow(ex, ex.message.orEmpty()))
} finally { } finally {
_processing.value = false _processing.value = false
@ -91,6 +93,15 @@ class TabState @Inject constructor(
} }
private fun exceptionContainsCancellation(ex: Throwable?): Boolean {
return when (ex) {
null -> false
ex.cause -> false
is CancellationException -> true
else -> exceptionContainsCancellation(ex.cause)
}
}
fun safeProcessingWithoutGit(showError: Boolean = true, callback: suspend CoroutineScope.() -> Unit) = fun safeProcessingWithoutGit(showError: Boolean = true, callback: suspend CoroutineScope.() -> Unit) =
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
_processing.value = true _processing.value = true