{"id":326853,"date":"2022-01-10T08:39:50","date_gmt":"2022-01-10T08:39:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326853"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326853","title":{"rendered":"<span>\u041e \u0434\u0435\u0431\u0430\u0433\u0435 Kotlin-\u043a\u043e\u0440\u0443\u0442\u0438\u043d<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0432 Kotlin.<\/p>\n<p><a href=\"https:\/\/kotlinlang.org\/docs\/coroutines-overview.html\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0432 Kotlin<\/a> &#8212; \u043e\u0434\u043d\u0430 \u0438\u0437 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447 \u044f\u0437\u044b\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043a\u043e\u0434 \u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b \u0432\u043e \u0432\u0441\u0451\u043c, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0445 \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c.<\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u043e\u0440\u0443\u0442\u0438\u043d &#8212; \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"kotlin\">import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking  data class UserDTO(     val id: Long,     val login: String )  suspend fun getUserByToken(token: String): UserDTO {     delay(100)     val id = 123L \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u044d\u0448, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e id     return getUserById(id) }  suspend fun getUserById(id: Long): UserDTO {     delay(100) \/\/\u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414     \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448\u0435 \u0438 \u0432 \u0411\u0414 \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c id \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     throw Exception(\"user not found\") }  fun main() {     try {         runBlocking {             getUserByToken(\"secretToken\")         }     } catch (e: Exception) {         e.printStackTrace()     } }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441:<\/p>\n<pre><code>java.lang.Exception: user not found   at MainKt.getUserById(main.kt:18)   at MainKt$getUserById$1.invokeSuspend(main.kt)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)   at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)   at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)   at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)   at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)   at kotlinx.coroutines.EventLoopImplBase$DelayedResumeTask.run(EventLoop.common.kt:494)   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279)   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)   at MainKt.main(main.kt:23)   at MainKt.main(main.kt)<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0440\u0435\u0439\u0441\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>getUserByToken<\/code>. \u0412 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0441\u0443\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>\u041a\u0443\u0434\u0430 \u0436\u0435 \u0434\u0435\u043b\u0441\u044f \u043f\u0440\u043e\u043f\u0430\u0432\u0448\u0438\u0439 \u0432\u044b\u0437\u043e\u0432? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 \u0438 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/JetBrains\/kotlin\/blob\/92d200e093c693b3c06e53a39e0b0973b84c7ec5\/kotlin-native\/runtime\/src\/main\/kotlin\/kotlin\/coroutines\/ContinuationImpl.kt#L19\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a> \u043a\u043e\u0440\u0443\u0442\u0438\u043d: \u043f\u0440\u0438 &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438&#187; (\u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>resumeWith<\/code>) \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430, \u0430 \u043b\u0438\u0448\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430 \u0432\u0441\u0435\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0438 \u0442.\u0434.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0435 \u043a\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0432 \u0435\u0451 \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430 \u044d\u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b.<\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u044f\u0441\u043d\u0430. \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 &#8212; \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u0436\u0438\u0437\u043d\u044c &#8212; \u0431\u043e\u043b\u044c \ud83d\ude41<\/p>\n<p>\u041d\u043e \u043f\u043e\u0433\u043e\u0434\u0438\u0442\u0435, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Kotlin&#8217;\u0430 \u043e \u043d\u0430\u0441 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0430 \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/Kotlin\/kotlinx.coroutines\/blob\/master\/docs\/topics\/debugging.md#stacktrace-recovery\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u0431\u0430\u0433-\u0440\u0435\u0436\u0438\u043c<\/a> \u0434\u043b\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u0431\u0430\u0433-\u0440\u0435\u0436\u0438\u043c\u0435(\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 -ea \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 JVM) \u0438 \u0432\u0438\u0434\u0438\u043c&#8230; \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412 \u0447\u0435\u043c \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0430? \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u0432\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u0434 Kotlin stdlib \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c&#187; (\u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>resumeWith<\/code> c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c). \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0441\u0430\u043c\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b, (\u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \ud83d\ude41<\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0443\u044e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d:<\/p>\n<ol>\n<li>\n<p>\u0412 \u0440\u0430\u0439\u0442\u0430\u0439\u043c\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f&#187;: \u043f\u0435\u0440\u0435\u0434 &#171;\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c&#187; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u0442\u0435\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a\u043e\u0439 \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/Anamorphosee\/stacktrace-decoroutinator\" rel=\"noopener noreferrer nofollow\">Stacktrace-decoroutinator<\/a>, \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0438 MethodHandle API. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f JVM >= 1.8 \u0438 \u0434\u043b\u044f Android API >= 26.<\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>dev.reformator.stacktracedecoroutinator:stacktrace-decoroutinator-jvm:2.1.0<\/code> \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>main<\/code> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code>import dev.reformator.stacktracedecoroutinator.runtime.DecoroutinatorRuntime import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking  data class UserDTO(     val id: Long,     val login: String )  suspend fun getUserByToken(token: String): UserDTO {     delay(100)     val id = 123L \/\/\u0441\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0435\u0448, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e id     return getUserById(id) }  suspend fun getUserById(id: Long): UserDTO {     delay(100) \/\/\u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414     \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0435\u0448\u0435 \u0438 \u0432 \u0411\u0414 \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c id \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     throw Exception(\"user not found\") }  fun main() {     DecoroutinatorRuntime.load() \/\/ \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c Stacktrace-decoroutinator     try {         runBlocking {             getUserByToken(\"secretToken\")         }     } catch (e: Exception) {         e.printStackTrace()     } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442, \u0432\u0438\u0434\u0438\u043c \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u0441 \u043f\u0440\u043e\u043f\u0430\u0432\u0448\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>getUserByToken<\/code>:<\/p>\n<pre><code>java.lang.Exception: user not found   at MainKt.getUserById(main.kt:19)   at MainKt$getUserById$1.invokeSuspend(main.kt)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.decoroutinatorResumeWith$lambda-1(continuation-stdlib.kt:47)   at MainKt.getUserByToken(main.kt:13)   at MainKt$main$1.invokeSuspend(main.kt:26)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.decoroutinatorResumeWith(continuation-stdlib.kt:177)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(continuation-stdlib.kt:21)   at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)   at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)   at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)   at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)   at kotlinx.coroutines.EventLoopImplBase$DelayedResumeTask.run(EventLoop.common.kt:494)   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279)   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)   at MainKt.main(main.kt:25)   at MainKt.main(main.kt)<\/code><\/pre>\n<p>\u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u0441\u0440\u0435\u0434\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0442\u044c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0441\u044f)<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/599655\/\"> https:\/\/habr.com\/ru\/post\/599655\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0432 Kotlin.<\/p>\n<p><a href=\"https:\/\/kotlinlang.org\/docs\/coroutines-overview.html\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0432 Kotlin<\/a> &#8212; \u043e\u0434\u043d\u0430 \u0438\u0437 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447 \u044f\u0437\u044b\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043a\u043e\u0434 \u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b \u0432\u043e \u0432\u0441\u0451\u043c, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0445 \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c.<\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u043e\u0440\u0443\u0442\u0438\u043d &#8212; \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"kotlin\">import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking  data class UserDTO(     val id: Long,     val login: String )  suspend fun getUserByToken(token: String): UserDTO {     delay(100)     val id = 123L \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u044d\u0448, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e id     return getUserById(id) }  suspend fun getUserById(id: Long): UserDTO {     delay(100) \/\/\u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414     \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448\u0435 \u0438 \u0432 \u0411\u0414 \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c id \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     throw Exception(\"user not found\") }  fun main() {     try {         runBlocking {             getUserByToken(\"secretToken\")         }     } catch (e: Exception) {         e.printStackTrace()     } }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0434 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441:<\/p>\n<pre><code>java.lang.Exception: user not found   at MainKt.getUserById(main.kt:18)   at MainKt$getUserById$1.invokeSuspend(main.kt)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)   at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)   at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)   at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)   at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)   at kotlinx.coroutines.EventLoopImplBase$DelayedResumeTask.run(EventLoop.common.kt:494)   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279)   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)   at MainKt.main(main.kt:23)   at MainKt.main(main.kt)<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0440\u0435\u0439\u0441\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>getUserByToken<\/code>. \u0412 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0441\u0443\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>\u041a\u0443\u0434\u0430 \u0436\u0435 \u0434\u0435\u043b\u0441\u044f \u043f\u0440\u043e\u043f\u0430\u0432\u0448\u0438\u0439 \u0432\u044b\u0437\u043e\u0432? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 \u0438 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/JetBrains\/kotlin\/blob\/92d200e093c693b3c06e53a39e0b0973b84c7ec5\/kotlin-native\/runtime\/src\/main\/kotlin\/kotlin\/coroutines\/ContinuationImpl.kt#L19\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a> \u043a\u043e\u0440\u0443\u0442\u0438\u043d: \u043f\u0440\u0438 &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438&#187; (\u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>resumeWith<\/code>) \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430, \u0430 \u043b\u0438\u0448\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430 \u0432\u0441\u0435\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0438 \u0442.\u0434.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0435 \u043a\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0432 \u0435\u0451 \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430 \u044d\u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b.<\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u044f\u0441\u043d\u0430. \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 &#8212; \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u0436\u0438\u0437\u043d\u044c &#8212; \u0431\u043e\u043b\u044c \ud83d\ude41<\/p>\n<p>\u041d\u043e \u043f\u043e\u0433\u043e\u0434\u0438\u0442\u0435, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Kotlin&#8217;\u0430 \u043e \u043d\u0430\u0441 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0430 \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/Kotlin\/kotlinx.coroutines\/blob\/master\/docs\/topics\/debugging.md#stacktrace-recovery\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u0431\u0430\u0433-\u0440\u0435\u0436\u0438\u043c<\/a> \u0434\u043b\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u0431\u0430\u0433-\u0440\u0435\u0436\u0438\u043c\u0435(\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 -ea \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 JVM) \u0438 \u0432\u0438\u0434\u0438\u043c&#8230; \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412 \u0447\u0435\u043c \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0430? \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u0432\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u0434 Kotlin stdlib \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c&#187; (\u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>resumeWith<\/code> c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c). \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0441\u0430\u043c\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b, (\u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \ud83d\ude41<\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0443\u044e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d:<\/p>\n<ol>\n<li>\n<p>\u0412 \u0440\u0430\u0439\u0442\u0430\u0439\u043c\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e &#171;\u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f&#187;: \u043f\u0435\u0440\u0435\u0434 &#171;\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c&#187; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u0442\u0435\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a\u043e\u0439 \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/Anamorphosee\/stacktrace-decoroutinator\" rel=\"noopener noreferrer nofollow\">Stacktrace-decoroutinator<\/a>, \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0438 MethodHandle API. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f JVM >= 1.8 \u0438 \u0434\u043b\u044f Android API >= 26.<\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <code>dev.reformator.stacktracedecoroutinator:stacktrace-decoroutinator-jvm:2.1.0<\/code> \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>main<\/code> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code>import dev.reformator.stacktracedecoroutinator.runtime.DecoroutinatorRuntime import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking  data class UserDTO(     val id: Long,     val login: String )  suspend fun getUserByToken(token: String): UserDTO {     delay(100)     val id = 123L \/\/\u0441\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0435\u0448, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e id     return getUserById(id) }  suspend fun getUserById(id: Long): UserDTO {     delay(100) \/\/\u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414     \/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0435\u0448\u0435 \u0438 \u0432 \u0411\u0414 \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c id \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     throw Exception(\"user not found\") }  fun main() {     DecoroutinatorRuntime.load() \/\/ \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c Stacktrace-decoroutinator     try {         runBlocking {             getUserByToken(\"secretToken\")         }     } catch (e: Exception) {         e.printStackTrace()     } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442, \u0432\u0438\u0434\u0438\u043c \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u0441 \u043f\u0440\u043e\u043f\u0430\u0432\u0448\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>getUserByToken<\/code>:<\/p>\n<pre><code>java.lang.Exception: user not found   at MainKt.getUserById(main.kt:19)   at MainKt$getUserById$1.invokeSuspend(main.kt)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.decoroutinatorResumeWith$lambda-1(continuation-stdlib.kt:47)   at MainKt.getUserByToken(main.kt:13)   at MainKt$main$1.invokeSuspend(main.kt:26)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.decoroutinatorResumeWith(continuation-stdlib.kt:177)   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(continuation-stdlib.kt:21)   at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)   at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)   at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)   at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)   at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:518)   at kotlinx.coroutines.EventLoopImplBase$DelayedResumeTask.run(EventLoop.common.kt:494)   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279)   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)   at MainKt.main(main.kt:25)   at MainKt.main(main.kt)<\/code><\/pre>\n<p>\u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u0441\u0440\u0435\u0434\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0442\u044c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0441\u044f)<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/599655\/\"> https:\/\/habr.com\/ru\/post\/599655\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326853","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326853"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326853\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}