mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-07 14:35:29 +01:00
Log errorCode when a stripe request fails.
This commit is contained in:
@@ -128,7 +128,19 @@ class StripeApi(
|
||||
if (response.isSuccessful) {
|
||||
return response
|
||||
} else {
|
||||
throw IOException("postForm failure: ${response.code()}")
|
||||
throw IOException("postForm failed with code: ${response.code()}. errorCode: ${parseErrorCode(response.body()?.string())}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseErrorCode(body: String?): String? {
|
||||
if (body == null) {
|
||||
return "No body."
|
||||
}
|
||||
|
||||
return try {
|
||||
JSONObject(body).getJSONObject("error").getString("code")
|
||||
} catch (e: Exception) {
|
||||
"Unable to parse error code."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user