diff options
| author | Niklas Berglund <niklas.berglund@gmail.com> | 2024-08-20 10:39:13 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2024-08-20 12:54:46 +0200 |
| commit | 1954b873f7089a76f4538d0cefa8e7bfc832e060 (patch) | |
| tree | 543400f722d8ef4634db659c61ea843ae8e6fcc2 /android/test/e2e/src | |
| parent | 5ea5191a6a29f9c88bc290e0f92d9b8eab41a540 (diff) | |
| download | mullvadvpn-1954b873f7089a76f4538d0cefa8e7bfc832e060.tar.xz mullvadvpn-1954b873f7089a76f4538d0cefa8e7bfc832e060.zip | |
Log response status code on error
Diffstat (limited to 'android/test/e2e/src')
| -rw-r--r-- | android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/SimpleMullvadHttpClient.kt | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/SimpleMullvadHttpClient.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/SimpleMullvadHttpClient.kt index a72f27a3ef..734f266537 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/SimpleMullvadHttpClient.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/SimpleMullvadHttpClient.kt @@ -4,6 +4,7 @@ import android.content.Context import androidx.test.services.events.TestEventException import co.touchlab.kermit.Logger import com.android.volley.Request +import com.android.volley.VolleyError import com.android.volley.toolbox.JsonArrayRequest import com.android.volley.toolbox.JsonObjectRequest import com.android.volley.toolbox.RequestFuture @@ -106,8 +107,9 @@ class SimpleMullvadHttpClient(context: Context) { authorizationHeader: String? = null ): JSONObject? { val future = RequestFuture.newFuture<JSONObject>() + val request = - object : JsonObjectRequest(method, url, body, future, future) { + object : JsonObjectRequest(method, url, body, future, onErrorResponse) { override fun getHeaders(): MutableMap<String, String> { val headers = HashMap<String, String>() if (body != null) { @@ -136,7 +138,7 @@ class SimpleMullvadHttpClient(context: Context) { ): String? { val future = RequestFuture.newFuture<String>() val request = - object : StringRequest(method, url, future, future) { + object : StringRequest(method, url, future, onErrorResponse) { override fun getHeaders(): MutableMap<String, String> { val headers = HashMap<String, String>() if (body != null) { @@ -165,7 +167,7 @@ class SimpleMullvadHttpClient(context: Context) { ): JSONArray? { val future = RequestFuture.newFuture<JSONArray>() val request = - object : JsonArrayRequest(method, url, null, future, future) { + object : JsonArrayRequest(method, url, null, future, onErrorResponse) { override fun getHeaders(): MutableMap<String, String> { val headers = HashMap<String, String>() headers.put("Content-Type", "application/json") @@ -190,5 +192,9 @@ class SimpleMullvadHttpClient(context: Context) { companion object { private const val REQUEST_ERROR_MESSAGE = "Unable to verify account due to invalid account or connectivity issues." + + private val onErrorResponse = { error: VolleyError -> + Logger.e("Response returned error status code: ${error.networkResponse.statusCode}") + } } } |
