File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
src/commonMain/kotlin/com.adamratzman.spotify Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import com.adamratzman.spotify.models.SpotifyAuthenticationException
7
7
import com.adamratzman.spotify.models.Token
8
8
import com.adamratzman.spotify.models.serialization.toObject
9
9
import com.adamratzman.spotify.utils.runBlocking
10
+ import kotlinx.coroutines.CancellationException
10
11
import kotlinx.coroutines.CoroutineScope
11
12
import kotlinx.coroutines.Job
12
13
import kotlinx.coroutines.launch
@@ -279,6 +280,8 @@ class SpotifyClientApiBuilder(
279
280
options.enableLogger,
280
281
options.testTokenValidity
281
282
)
283
+ } catch (e: CancellationException ) {
284
+ throw e
282
285
} catch (e: Exception ) {
283
286
throw SpotifyAuthenticationException (" Invalid credentials provided in the login process" , e)
284
287
}
@@ -378,6 +381,8 @@ class SpotifyAppApiBuilder(
378
381
options.enableLogger,
379
382
options.testTokenValidity
380
383
)
384
+ } catch (e: CancellationException ) {
385
+ throw e
381
386
} catch (e: Exception ) {
382
387
throw SpotifyAuthenticationException (" Invalid credentials provided in the login process" , e)
383
388
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import kotlin.coroutines.resume
11
11
import kotlin.coroutines.resumeWithException
12
12
import kotlin.coroutines.suspendCoroutine
13
13
import kotlin.jvm.JvmOverloads
14
+ import kotlinx.coroutines.CancellationException
14
15
import kotlinx.coroutines.CoroutineScope
15
16
import kotlinx.coroutines.Dispatchers
16
17
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -73,6 +74,8 @@ open class SpotifyRestAction<T> internal constructor(protected val api: SpotifyA
73
74
hasRunBacking = true
74
75
return @withContext try {
75
76
supplier().also { hasCompletedBacking = true }
77
+ } catch (e: CancellationException ) {
78
+ throw e
76
79
} catch (e: Throwable ) {
77
80
throw e
78
81
}
@@ -91,6 +94,8 @@ open class SpotifyRestAction<T> internal constructor(protected val api: SpotifyA
91
94
try {
92
95
val result = suspendComplete()
93
96
consumer(result)
97
+ } catch (e: CancellationException ) {
98
+ throw e
94
99
} catch (t: Throwable ) {
95
100
failure(t)
96
101
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import io.ktor.http.ContentType
16
16
import io.ktor.http.HttpMethod
17
17
import io.ktor.http.content.ByteArrayContent
18
18
import io.ktor.http.content.TextContent
19
+ import kotlinx.coroutines.CancellationException
19
20
import kotlinx.coroutines.delay
20
21
import kotlinx.io.core.toByteArray
21
22
import kotlinx.io.core.use
@@ -138,6 +139,8 @@ internal class HttpConnection constructor(
138
139
}
139
140
)
140
141
}
142
+ } catch (e: CancellationException ) {
143
+ throw e
141
144
} catch (e: ResponseException ) {
142
145
throw SpotifyException .BadRequestException (e)
143
146
}
You can’t perform that action at this time.
0 commit comments