@@ -65,7 +65,7 @@ internal actual suspend inline fun recoverAndThrow(exception: Throwable): Nothin
65
65
if (recoveryDisabled(exception)) throw exception
66
66
suspendCoroutineUninterceptedOrReturn<Nothing > {
67
67
if (it !is CoroutineStackFrame ) throw exception
68
- throw recoverFromStackFrame(exception, it)
68
+ throw recoverFromStackFrame(exception, it)
69
69
}
70
70
}
71
71
@@ -86,34 +86,7 @@ internal actual fun <E : Throwable> unwrap(exception: E): E {
86
86
private fun <E : Throwable > recoveryDisabled (exception : E ) =
87
87
! RECOVER_STACKTRACE || ! DEBUG || exception is CancellationException || exception is NonRecoverableThrowable
88
88
89
- @Suppress(" UNCHECKED_CAST" )
90
- private fun <E : Throwable > tryCopyException (exception : E ): E ? {
91
- /*
92
- * Try to reflectively find constructor(), constructor(message, cause) or constructor(cause).
93
- * Exceptions are shared among coroutines, so we should copy exception before recovering current stacktrace.
94
- */
95
- var newException: E ? = null
96
- try {
97
- val constructors = exception.javaClass.constructors.sortedByDescending { it.parameterTypes.size }
98
- for (constructor in constructors) {
99
- val parameters = constructor .parameterTypes
100
- if (parameters.size == 2 && parameters[0 ] == String ::class .java && parameters[1 ] == Throwable ::class .java) {
101
- newException = constructor .newInstance(exception.message, exception) as E
102
- } else if (parameters.size == 1 && parameters[0 ] == Throwable ::class .java) {
103
- newException = constructor .newInstance(exception) as E
104
- } else if (parameters.isEmpty()) {
105
- newException = (constructor .newInstance() as E ).also { it.initCause(exception) }
106
- }
107
-
108
- if (newException != null ) {
109
- break
110
- }
111
- }
112
- } catch (e: Exception ) {
113
- // Do nothing
114
- }
115
- return newException
116
- }
89
+
117
90
118
91
private fun createStackTrace (continuation : CoroutineStackFrame ): ArrayList <StackTraceElement > {
119
92
val stack = ArrayList <StackTraceElement >()
0 commit comments