diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/git/TabState.kt b/src/main/kotlin/com/jetpackduba/gitnuro/git/TabState.kt index de4e4b9..08eb25a 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/git/TabState.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/git/TabState.kt @@ -78,7 +78,9 @@ class TabState @Inject constructor( refreshEvenIfCrashesInteractiveResult = refreshEvenIfCrashesInteractive?.invoke(ex) ?: false - if (showError) + val containsCancellation = exceptionContainsCancellation(ex) + + if (showError && !containsCancellation) errorsManager.addError(newErrorNow(ex, ex.message.orEmpty())) } finally { _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) = scope.launch(Dispatchers.IO) { _processing.value = true