Skip to content

Commit 6a57d8f

Browse files
committed
Review: save val cause
1 parent 0b28774 commit 6a57d8f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

kotlinx-coroutines-core/common/src/CoroutineExceptionHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.coroutines.*
1616
*/
1717
@InternalCoroutinesApi
1818
public fun handleCoroutineException(context: CoroutineContext, exception: Throwable) {
19-
val reportException = if (exception is DispatchException) exception.cause!! else exception
19+
val reportException = if (exception is DispatchException) exception.cause else exception
2020
// Invoke an exception handler from the context if present
2121
try {
2222
context[CoroutineExceptionHandler]?.let {

kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal abstract class DispatchedTask<in T> internal constructor(
113113
val result = runCatching { taskContext.afterTask() }
114114
handleFatalException(fatalException, result.exceptionOrNull())
115115
if (dispatchException != null) {
116-
handleCoroutineException(delegate.context, dispatchException.cause!!)
116+
handleCoroutineException(delegate.context, dispatchException.cause)
117117
}
118118
}
119119
}

kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private fun dispatcherFailure(completion: Continuation<*>, e: Throwable) {
6060
* 2) Rethrow the exception immediately, so it will crash the caller (e.g. when the coroutine had
6161
* no parent or it was async/produce over MainScope).
6262
*/
63-
val reportException = if (e is DispatchException) e.cause!! else e
63+
val reportException = if (e is DispatchException) e.cause else e
6464
completion.resumeWith(Result.failure(reportException))
6565
throw reportException
6666
}

0 commit comments

Comments
 (0)