Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3841ddd2 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

GPlayHttpClient - check InterruptedIOException for timeout

parent 71b4fedb
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import timber.log.Timber
import java.io.IOException
import java.io.InterruptedIOException
import java.net.SocketTimeoutException
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -169,7 +170,11 @@ class GPlayHttpClient @Inject constructor(
        } catch (e: GplayHttpRequestException) {
            throw e
        } catch (e: Exception) {
            val status = if (e is SocketTimeoutException) STATUS_CODE_TIMEOUT else -1
            val status = when {
                e is SocketTimeoutException -> STATUS_CODE_TIMEOUT
                e is InterruptedIOException && e.message == "timeout" -> STATUS_CODE_TIMEOUT
                else -> -1
            }
            throw GplayHttpRequestException(status, e.localizedMessage ?: "")
        } finally {
            response?.close()