forked from github/wulkanowy-mirror
parent
5a997dacb7
commit
b3cd7e8ac1
@ -19,7 +19,11 @@ import io.github.wulkanowy.di.DaggerAppComponent
|
||||
import io.github.wulkanowy.services.sync.SyncWorkerFactory
|
||||
import io.github.wulkanowy.utils.CrashlyticsTree
|
||||
import io.github.wulkanowy.utils.DebugLogTree
|
||||
import io.reactivex.exceptions.UndeliverableException
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import java.lang.Exception
|
||||
import javax.inject.Inject
|
||||
|
||||
class WulkanowyApp : DaggerApplication() {
|
||||
@ -42,6 +46,7 @@ class WulkanowyApp : DaggerApplication() {
|
||||
if (DEBUG) enableDebugLog()
|
||||
AppCompatDelegate.setDefaultNightMode(prefRepository.currentTheme)
|
||||
WorkManager.initialize(this, Configuration.Builder().setWorkerFactory(workerFactory).build())
|
||||
RxJavaPlugins.setErrorHandler(::onError)
|
||||
}
|
||||
|
||||
private fun enableDebugLog() {
|
||||
@ -56,6 +61,12 @@ class WulkanowyApp : DaggerApplication() {
|
||||
Timber.plant(CrashlyticsTree())
|
||||
}
|
||||
|
||||
private fun onError(t: Throwable) {
|
||||
if (t is UndeliverableException && t.cause is IOException || t.cause is InterruptedException) {
|
||||
Timber.e(t.cause, "An undeliverable error occurred")
|
||||
} else throw t
|
||||
}
|
||||
|
||||
override fun applicationInjector(): AndroidInjector<out DaggerApplication> {
|
||||
return DaggerAppComponent.builder().create(this)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user