Displays an error message when it cannot parse the returning json from relays.

This commit is contained in:
Vitor Pamplona
2023-06-23 17:57:21 -04:00
parent 9e57a706ae
commit e1cf188fbe
2 changed files with 17 additions and 6 deletions
@@ -305,6 +305,7 @@ fun loadRelayInfo(
object : Callback { object : Callback {
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
response.use { response.use {
try {
if (it.isSuccessful) { if (it.isSuccessful) {
onInfo(RelayInformation.fromJson(it.body.string())) onInfo(RelayInformation.fromJson(it.body.string()))
} else { } else {
@@ -312,7 +313,17 @@ fun loadRelayInfo(
Toast Toast
.makeText( .makeText(
context, context,
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information), context.getString(R.string.an_error_ocurred_trying_to_get_relay_information, dirtyUrl),
Toast.LENGTH_SHORT
).show()
}
}
} catch (e: Exception) {
scope.launch {
Toast
.makeText(
context,
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information, dirtyUrl),
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
} }
@@ -326,7 +337,7 @@ fun loadRelayInfo(
Toast Toast
.makeText( .makeText(
context, context,
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information), context.getString(R.string.an_error_ocurred_trying_to_get_relay_information, dirtyUrl),
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
} }
+1 -1
View File
@@ -433,7 +433,7 @@
<string name="sats_to_complete">Zapraiser at %1$s. %2$s sats to goal</string> <string name="sats_to_complete">Zapraiser at %1$s. %2$s sats to goal</string>
<string name="read_from_relay">Read from Relay</string> <string name="read_from_relay">Read from Relay</string>
<string name="write_to_relay">Write to Relay</string> <string name="write_to_relay">Write to Relay</string>
<string name="an_error_ocurred_trying_to_get_relay_information">An error ocurred trying to get relay information</string> <string name="an_error_ocurred_trying_to_get_relay_information">An error ocurred trying to get relay information from %1$s</string>
<string name="owner">Owner</string> <string name="owner">Owner</string>
<string name="version">Version</string> <string name="version">Version</string>
<string name="software">Software</string> <string name="software">Software</string>