Skip to content

Commit

Permalink
fix unnecessary check in recover()
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Dec 21, 2023
1 parent 40369ca commit 244c297
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ internal fun interface RecoverModule<S : MVIState, I : MVIIntent, A : MVIAction>
withContext(this@RecoverModule) { block() }
} catch (expected: Exception) {
when {
alreadyRecovered() -> throw RecursiveRecoverException(expected)
expected is CancellationException || expected is UnrecoverableException -> throw expected
alreadyRecovered() -> throw RecursiveRecoverException(expected)
else -> recover(expected)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import pro.respawn.flowmvi.modules.RecoverModule
import pro.respawn.flowmvi.modules.StateModule
import pro.respawn.flowmvi.modules.SubscribersModule
import pro.respawn.flowmvi.modules.actionModule
import pro.respawn.flowmvi.modules.alreadyRecovered
import pro.respawn.flowmvi.modules.intentModule
import pro.respawn.flowmvi.modules.launchPipeline
import pro.respawn.flowmvi.modules.observeSubscribers
Expand Down Expand Up @@ -83,7 +82,6 @@ internal class StoreImpl<S : MVIState, I : MVIIntent, A : MVIAction>(
}

override suspend fun PipelineContext<S, I, A>.recover(e: Exception) {
if (alreadyRecovered()) throw e
withContext(this@StoreImpl) {
onException(e)?.let { throw UnhandledStoreException(it) }
}
Expand Down

0 comments on commit 244c297

Please sign in to comment.