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

Commit ba7c3584 authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch 'exception_gplay_#4950' into epic_176-all-refactorAndGplay

parents 5bb776e7 ba4a2f1f
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import java.io.IOException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -156,10 +157,18 @@ class GPlayHttpClient @Inject constructor(
        return try {
            val call = okHttpClient.newCall(request)
            buildPlayResponse(call.execute())
        } catch (e: UnknownHostException) {
            Log.e(TAG, "processRequest: ${e.localizedMessage}")
            PlayResponse()
        } catch (e: Exception) {
            when (e) {
                is UnknownHostException,
                is SocketTimeoutException -> handleExceptionOnGooglePlayRequest(e)
                else -> handleExceptionOnGooglePlayRequest(e)
            }
        }
    }

    private fun handleExceptionOnGooglePlayRequest(e: Exception): PlayResponse {
        Log.e(TAG, "processRequest: ${e.localizedMessage}")
        return PlayResponse()
    }

    private fun buildUrl(url: String, params: Map<String, String>): HttpUrl {