summaryrefslogtreecommitdiff
path: root/merchant-lib/src/main/java/net/taler/merchantlib/Response.kt
diff options
context:
space:
mode:
Diffstat (limited to 'merchant-lib/src/main/java/net/taler/merchantlib/Response.kt')
-rw-r--r--merchant-lib/src/main/java/net/taler/merchantlib/Response.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/merchant-lib/src/main/java/net/taler/merchantlib/Response.kt b/merchant-lib/src/main/java/net/taler/merchantlib/Response.kt
index 1b49d78..9aefa5f 100644
--- a/merchant-lib/src/main/java/net/taler/merchantlib/Response.kt
+++ b/merchant-lib/src/main/java/net/taler/merchantlib/Response.kt
@@ -16,8 +16,11 @@
package net.taler.merchantlib
+import android.util.Log
import io.ktor.client.call.receive
import io.ktor.client.features.ClientRequestException
+import io.ktor.client.features.ResponseException
+import io.ktor.client.features.ServerResponseException
import kotlinx.serialization.Serializable
class Response<out T> private constructor(
@@ -29,6 +32,7 @@ class Response<out T> private constructor(
return try {
success(request())
} catch (e: Throwable) {
+ Log.e("merchant-lib", "Error", e)
failure(e)
}
}
@@ -63,10 +67,11 @@ class Response<out T> private constructor(
private suspend fun getFailureString(failure: Failure): String = when (failure.exception) {
is ClientRequestException -> getExceptionString(failure.exception)
+ is ServerResponseException -> getExceptionString(failure.exception)
else -> failure.exception.toString()
}
- private suspend fun getExceptionString(e: ClientRequestException): String {
+ private suspend fun getExceptionString(e: ResponseException): String {
return try {
val error: Error = e.response.receive()
"Error ${error.code}: ${error.hint}"