Added RxJava global error handler to avoid anoying the user by avoiding crashes when an error occurs on a RxJava operation, but still log the exception to Crashlytics so that we can fix the issues.

This commit is contained in:
Severiano Jaramillo 2019-03-18 21:24:15 -06:00
parent 776e5f42b7
commit 1728cef152

View file

@ -1,27 +1,36 @@
package cy.agorise.bitsybitshareswallet.utils package cy.agorise.bitsybitshareswallet.utils
import android.app.Application import android.app.Application
import com.crashlytics.android.Crashlytics
import cy.agorise.graphenej.api.ApiAccess import cy.agorise.graphenej.api.ApiAccess
import cy.agorise.graphenej.api.android.NetworkServiceManager import cy.agorise.graphenej.api.android.NetworkServiceManager
import io.reactivex.plugins.RxJavaPlugins
class BitsyApplication : Application() { class BitsyApplication : Application() {
private val BITSHARES_NODE_URLS = arrayOf( companion object {
// PP private nodes private val BITSHARES_NODE_URLS = arrayOf(
"wss://nl.palmpay.io/ws", // PP private nodes
"wss://nl.palmpay.io/ws",
// Other public nodes // Other public nodes
"wss://bitshares.nu/ws", // Stockholm, Sweden "wss://bitshares.nu/ws", // Stockholm, Sweden
"wss://bitshares.openledger.info/ws", // Openledger node "wss://bitshares.openledger.info/ws", // Openledger node
"wss://dallas.bitshares.apasia.tech/ws", // Dallas, USA "wss://dallas.bitshares.apasia.tech/ws", // Dallas, USA
"wss://atlanta.bitshares.apasia.tech/ws", // Atlanta, USA "wss://atlanta.bitshares.apasia.tech/ws", // Atlanta, USA
"wss://dex.rnglab.org", // Amsterdam, Netherlands "wss://dex.rnglab.org", // Amsterdam, Netherlands
"wss://citadel.li/node" "wss://citadel.li/node"
) )
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
// Add RxJava error handler to avoid crashes when an error occurs on a RxJava operation, but still log the
// exception to Crashlytics so that we can fix the issues
RxJavaPlugins.setErrorHandler { throwable -> Crashlytics.logException(throwable)}
// Specifying some important information regarding the connection, such as the // Specifying some important information regarding the connection, such as the
// credentials and the requested API accesses // credentials and the requested API accesses
val requestedApis = ApiAccess.API_DATABASE or ApiAccess.API_HISTORY or ApiAccess.API_NETWORK_BROADCAST val requestedApis = ApiAccess.API_DATABASE or ApiAccess.API_HISTORY or ApiAccess.API_NETWORK_BROADCAST