mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-06-02 07:55:13 +00:00
16 lines
365 B
Kotlin
16 lines
365 B
Kotlin
package dev.inmo.micro_utils.ktor.client
|
|
|
|
import io.ktor.client.plugins.ClientRequestException
|
|
import io.ktor.client.statement.HttpResponse
|
|
import io.ktor.http.isSuccess
|
|
|
|
inline fun HttpResponse.throwOnUnsuccess(
|
|
unsuccessMessage: () -> String
|
|
) {
|
|
if (status.isSuccess()) {
|
|
return
|
|
}
|
|
|
|
throw ClientRequestException(this, unsuccessMessage())
|
|
}
|