Skip to content

Commit

Permalink
use kotlinCause instead of looking at userInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushg committed Feb 17, 2022
1 parent 8b408dc commit 12a8509
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ class NSErrorTests {
fun `ensure exception is part of user info`() {
val exception = RandomException()
val nsError = exception.asNativeError()
assertSame(exception, nsError.userInfo["KotlinException"], "Exception isn't part of the user info")
assertSame(exception, nsError.kotlinCause, "Exception isn't part of the user info")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NativeFlowTests {
val completionCount = atomic(0)
nativeFlow({ _, _ -> }, { error, _ ->
assertNotNull(error, "Flow should complete with an error")
val kotlinException = error.userInfo["KotlinException"]
val kotlinException = error.kotlinCause
assertSame(exception, kotlinException, "Kotlin exception should be the same exception")
completionCount.incrementAndGet()
})
Expand Down Expand Up @@ -76,7 +76,7 @@ class NativeFlowTests {
val completionCount = atomic(0)
val cancel = nativeFlow({ _, _ -> }, { error, _ ->
assertNotNull(error, "Flow should complete with an error")
val exception = error.userInfo["KotlinException"]
val exception = error.kotlinCause
assertIs<CancellationException>(exception, "Error should contain CancellationException")
completionCount.incrementAndGet()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class NativeSuspendTests {
receivedResultCount.incrementAndGet()
}, { error, _ ->
assertNotNull(error, "Function should complete with an error")
val kotlinException = error.userInfo["KotlinException"]
val kotlinException = error.kotlinCause
assertSame(exception, kotlinException, "Kotlin exception should be the same exception")
receivedErrorCount.incrementAndGet()
})
Expand All @@ -77,7 +77,7 @@ class NativeSuspendTests {
receivedResultCount.incrementAndGet()
}, { error, _ ->
assertNotNull(error, "Function should complete with an error")
val exception = error.userInfo["KotlinException"]
val exception = error.kotlinCause
assertIs<CancellationException>(exception, "Error should contain CancellationException")
receivedErrorCount.incrementAndGet()
})
Expand Down

0 comments on commit 12a8509

Please sign in to comment.