@@ -14,10 +14,10 @@ import kotlin.coroutines.*
14
14
import kotlin.internal.*
15
15
16
16
/* *
17
- * Creates cold [mono][Mono] that will run a given [block] in a coroutine and emits its result.
17
+ * Creates cold [mono][Mono] that runs a given [block] in a coroutine and emits its result.
18
18
* Every time the returned mono is subscribed, it starts a new coroutine.
19
- * If [block] completes with `null` or its execution was cancelled , [MonoSink.success] is invoked without a value.
20
- * Unsubscribing cancels running coroutine.
19
+ * If the result of [block] is `null`, [MonoSink.success] is invoked without a value.
20
+ * Unsubscribing cancels the running coroutine.
21
21
*
22
22
* Coroutine context can be specified with [context] argument.
23
23
* If the context does not have any dispatcher nor any other [ContinuationInterceptor], then [Dispatchers.Default] is used.
@@ -84,16 +84,16 @@ private class MonoCoroutine<in T>(
84
84
}
85
85
86
86
override fun onCancelled (cause : Throwable , handled : Boolean ) {
87
- try {
88
- /* * Cancellation exceptions that were caused by [dispose], that is, came from downstream, are not errors. */
89
- if (getCancellationException() != = cause || ! disposed) {
87
+ /* * Cancellation exceptions that were caused by [dispose], that is, came from downstream, are not errors. */
88
+ if (getCancellationException() != = cause || ! disposed) {
89
+ try {
90
90
/* * If [sink] turns out to already be in a terminal state, this exception will be passed through the
91
91
* [Hooks.onErrorDropped] hook, which is the way to signal undeliverable exceptions in Reactor. */
92
92
sink.error(cause)
93
+ } catch (e: Throwable ) {
94
+ // In case of improper error implementation or fatal exceptions
95
+ handleCoroutineException(context, cause)
93
96
}
94
- } catch (e: Throwable ) {
95
- // In case of improper error implementation or fatal exceptions
96
- handleCoroutineException(context, cause)
97
97
}
98
98
}
99
99
0 commit comments