Improves Logs when the app cannot connect with relays.

This commit is contained in:
Vitor Pamplona
2023-06-23 18:02:04 -04:00
parent e1cf188fbe
commit aa931a4cc5
@@ -1,6 +1,7 @@
package com.vitorpamplona.amethyst.ui.actions package com.vitorpamplona.amethyst.ui.actions
import android.content.Context import android.content.Context
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@@ -305,9 +306,10 @@ fun loadRelayInfo(
object : Callback { object : Callback {
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
response.use { response.use {
val body = it.body.string()
try { try {
if (it.isSuccessful) { if (it.isSuccessful) {
onInfo(RelayInformation.fromJson(it.body.string())) onInfo(RelayInformation.fromJson(body))
} else { } else {
scope.launch { scope.launch {
Toast Toast
@@ -319,6 +321,7 @@ fun loadRelayInfo(
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.e("RelayInfoFail", "Resulting Message from Relay in not parseable: $body", e)
scope.launch { scope.launch {
Toast Toast
.makeText( .makeText(
@@ -332,7 +335,7 @@ fun loadRelayInfo(
} }
override fun onFailure(call: Call, e: IOException) { override fun onFailure(call: Call, e: IOException) {
e.printStackTrace() Log.e("RelayInfoFail", "Resulting Message from Relay in not parseable", e)
scope.launch { scope.launch {
Toast Toast
.makeText( .makeText(