mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-11-20 01:26:11 +00:00
Log Wallet Connect init failures; give empty errors a text; retranslate Kurmanji (#33)
* Log Wallet Connect init failures; give empty network errors a text - Wallet Connect core and Web3Wallet initialization errors were swallowed silently; log them. A retry is not added: initialization fails only on bad configuration, and the relay connects later on demand. - NovaException.networkError carried an empty message; it now uses the existing translated connection error text. The unused NovaException.unexpectedError is removed. - BaseException.unexpectedError fell back to an empty message when the exception had none; HttpExceptionHandler now passes the translated common error text as the fallback. - Remove the unused AccountRepository.getMyAccounts stub. * Retranslate the Kurmanji strings The values-ku file was word-by-word machine output that mixed English and Kurmanji (1709 of 2080 strings had English left in, 620 were English verbatim). Rebuild it from the English source with a fixed wallet glossary: every translatable string and plural is translated, 18 strings that were missing are added, and strings marked translatable="false" or no longer in the English source are dropped. * Skip commented-out strings in the Kurmanji file Two English strings have an older, commented-out copy; reading the comments emitted each of them twice and failed resource merging.
This commit is contained in:
1 parent
de826acc70
commit
58ef588261
8 files changed
+1954
-2628
No files matched your search
@@ -29,8 +29,8 @@ class BaseException(
|
||||
return BaseException(Kind.NETWORK, message, exception)
|
||||
}
|
||||
|
||||
fun unexpectedError(exception: Throwable): BaseException {
|
||||
return BaseException(Kind.UNEXPECTED, exception.message ?: "", exception)
|
||||
fun unexpectedError(fallbackMessage: String, exception: Throwable): BaseException {
|
||||
return BaseException(Kind.UNEXPECTED, exception.message ?: fallbackMessage, exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.novafoundation.nova.common.base.errors
|
||||
|
||||
import io.novafoundation.nova.common.R
|
||||
import io.novafoundation.nova.common.resources.ResourceManager
|
||||
|
||||
class NovaException(
|
||||
@@ -16,11 +17,7 @@ class NovaException(
|
||||
companion object {
|
||||
|
||||
fun networkError(resourceManager: ResourceManager, throwable: Throwable): NovaException {
|
||||
return NovaException(Kind.NETWORK, "", throwable) // TODO: add common error text to resources
|
||||
}
|
||||
|
||||
fun unexpectedError(exception: Throwable): NovaException {
|
||||
return NovaException(Kind.UNEXPECTED, exception.message ?: "", exception) // TODO: add common error text to resources
|
||||
return NovaException(Kind.NETWORK, resourceManager.getString(R.string.connection_error_message_v2_2_0), throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ class HttpExceptionHandler(
|
||||
BaseException.httpError(errorCode, resourceManager.getString(R.string.common_undefined_error_message))
|
||||
}
|
||||
is IOException -> BaseException.networkError(resourceManager.getString(R.string.connection_error_message_v2_2_0), exception)
|
||||
else -> BaseException.unexpectedError(exception)
|
||||
else -> BaseException.unexpectedError(resourceManager.getString(R.string.common_undefined_error_message), exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1897
-2606
File diff suppressed because it is too large.
Load diff
+46
@@ -0,0 +1,46 @@
|
||||
package io.novafoundation.nova.common.data.network
|
||||
|
||||
import io.novafoundation.nova.common.R
|
||||
import io.novafoundation.nova.common.base.BaseException
|
||||
import io.novafoundation.nova.common.base.errors.NovaException
|
||||
import io.novafoundation.nova.common.resources.ResourceManager
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito
|
||||
import java.io.IOException
|
||||
|
||||
class HttpExceptionHandlerTest {
|
||||
|
||||
private val resourceManager = Mockito.mock(ResourceManager::class.java).also {
|
||||
Mockito.`when`(it.getString(R.string.common_undefined_error_message)).thenReturn(UNDEFINED)
|
||||
Mockito.`when`(it.getString(R.string.connection_error_message_v2_2_0)).thenReturn(CONNECTION)
|
||||
}
|
||||
|
||||
private val handler = HttpExceptionHandler(resourceManager)
|
||||
|
||||
@Test
|
||||
fun `an unexpected error without a message gets the common error text`() {
|
||||
val error = handler.transformException(IllegalStateException())
|
||||
|
||||
assertEquals(BaseException.Kind.UNEXPECTED, error.kind)
|
||||
assertEquals(UNDEFINED, error.message)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an unexpected error keeps its own message`() {
|
||||
assertEquals("boom", handler.transformException(IllegalStateException("boom")).message)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a socket network error carries the connection error text`() {
|
||||
val error = NovaException.networkError(resourceManager, IOException())
|
||||
|
||||
assertEquals(NovaException.Kind.NETWORK, error.kind)
|
||||
assertEquals(CONNECTION, error.message)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val UNDEFINED = "undefined"
|
||||
const val CONNECTION = "connection"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user