do not catch Worker exceptions
This commit is contained in:
parent
23e60084d0
commit
413d958c87
1 changed files with 3 additions and 10 deletions
|
@ -3,7 +3,6 @@ package info.nightscout.core.utils.worker
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.work.CoroutineWorker
|
import androidx.work.CoroutineWorker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import androidx.work.workDataOf
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
|
@ -23,17 +22,11 @@ abstract class LoggingWorker(context: Context, workerParams: WorkerParameters, p
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun doWork(): Result =
|
override suspend fun doWork(): Result =
|
||||||
try {
|
|
||||||
withContext(dispatcher) {
|
withContext(dispatcher) {
|
||||||
doWorkAndLog().also {
|
doWorkAndLog().also {
|
||||||
aapsLogger.debug(LTag.WORKER, "Worker result ${it::class.java.simpleName.uppercase()} for ${this@LoggingWorker::class.java}")
|
aapsLogger.debug(LTag.WORKER, "Worker result ${it::class.java.simpleName.uppercase()} for ${this@LoggingWorker::class.java}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
fabricPrivacy.logException(e)
|
|
||||||
e.printStackTrace()
|
|
||||||
Result.failure(workDataOf("Error" to e.localizedMessage))
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract suspend fun doWorkAndLog(): Result
|
abstract suspend fun doWorkAndLog(): Result
|
||||||
}
|
}
|
Loading…
Reference in a new issue