@@ -56,12 +56,11 @@ public interface CoroutineExceptionHandler : CoroutineContext.Element {
56
56
/* *
57
57
* Creates new [CoroutineExceptionHandler] instance.
58
58
* @param handler a function which handles exception thrown by a coroutine
59
+ * @suppress **Deprecated**
59
60
*/
61
+ @Deprecated(" Replaced with top-level function" , level = DeprecationLevel .HIDDEN )
60
62
public operator inline fun invoke (crossinline handler : (CoroutineContext , Throwable ) -> Unit ): CoroutineExceptionHandler =
61
- object : AbstractCoroutineContextElement (Key ), CoroutineExceptionHandler {
62
- override fun handleException (context : CoroutineContext , exception : Throwable ) =
63
- handler.invoke(context, exception)
64
- }
63
+ CoroutineExceptionHandler (handler)
65
64
}
66
65
67
66
/* *
@@ -70,3 +69,13 @@ public interface CoroutineExceptionHandler : CoroutineContext.Element {
70
69
*/
71
70
public fun handleException (context : CoroutineContext , exception : Throwable )
72
71
}
72
+
73
+ /* *
74
+ * Creates new [CoroutineExceptionHandler] instance.
75
+ * @param handler a function which handles exception thrown by a coroutine
76
+ */
77
+ public inline fun CoroutineExceptionHandler (crossinline handler : (CoroutineContext , Throwable ) -> Unit ): CoroutineExceptionHandler =
78
+ object : AbstractCoroutineContextElement (CoroutineExceptionHandler ), CoroutineExceptionHandler {
79
+ override fun handleException (context : CoroutineContext , exception : Throwable ) =
80
+ handler.invoke(context, exception)
81
+ }
0 commit comments