Skip to content

Commit 13aea06

Browse files
authored
Properly propagate observation cancellations (#266)
Cancellations of observations should not be captured/handled by the observation exception handler.
1 parent b41e51a commit 13aea06

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

core/src/commonMain/kotlin/Observers.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ internal class Observers<T>(
6767
.onSubscription {
6868
try {
6969
observation.onSubscription(onSubscription)
70+
} catch (e: CancellationException) {
71+
throw e
7072
} catch (e: Exception) {
7173
exceptionHandler(ObservationExceptionPeripheral(peripheral), e)
7274
}
@@ -80,6 +82,8 @@ internal class Observers<T>(
8082
.onCompletion {
8183
try {
8284
observation.onCompletion(onSubscription)
85+
} catch (e: CancellationException) {
86+
throw e
8387
} catch (e: Exception) {
8488
exceptionHandler(ObservationExceptionPeripheral(peripheral), e)
8589
}

0 commit comments

Comments
 (0)