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

View File

@ -305,14 +305,25 @@ fun loadRelayInfo(
object : Callback {
override fun onResponse(call: Call, response: Response) {
response.use {
if (it.isSuccessful) {
onInfo(RelayInformation.fromJson(it.body.string()))
} else {
try {
if (it.isSuccessful) {
onInfo(RelayInformation.fromJson(it.body.string()))
} else {
scope.launch {
Toast
.makeText(
context,
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),
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information, dirtyUrl),
Toast.LENGTH_SHORT
).show()
}
@ -326,7 +337,7 @@ fun loadRelayInfo(
Toast
.makeText(
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()
}

View File

@ -433,7 +433,7 @@
<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="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="version">Version</string>
<string name="software">Software</string>