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,11 +1,15 @@
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() {
companion object {
private val BITSHARES_NODE_URLS = arrayOf( private val BITSHARES_NODE_URLS = arrayOf(
// PP private nodes // PP private nodes
"wss://nl.palmpay.io/ws", "wss://nl.palmpay.io/ws",
@ -18,10 +22,15 @@ class BitsyApplication : Application() {
"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