Skip to content

Commit d8f9fb6

Browse files
committed
fixup! improve Stats failure handling
1 parent 220fb1f commit d8f9fb6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

util/okhttp-kts/src/main/kotlin/okhttp-ktx.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ fun OkHttpClient.postForm(
199199
*/
200200
fun Response.checkSuccess() {
201201
if (code !in 200..399) {
202-
throw HttpStatusCodeException(code, message)
202+
readText(skipStatusCheck = true)
203+
throw HttpStatusCodeException(code, message, this)
203204
}
204205
val location = getLocationUnchecked()
205206
if (location != null) {
@@ -211,7 +212,7 @@ fun Response.checkSuccess() {
211212
}
212213
}
213214

214-
class HttpStatusCodeException(code: Int, message: String) : IllegalStateException("$code $message")
215+
class HttpStatusCodeException(val code: Int, message: String, val response: Response) : IllegalStateException("$code $message")
215216

216217
/**
217218
* Retrieves the redirect location from the HTTP response.

0 commit comments

Comments
 (0)