diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt index 55a1c3a98a..34bc3a244c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.food import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -55,7 +56,7 @@ class FoodPlugin @Inject constructor( override fun doWork(): Result { val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods") var ret = Result.success() @@ -77,7 +78,7 @@ class FoodPlugin @Inject constructor( repository.runTransactionForResult(SyncNsFoodTransaction(delFood)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while removing food", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { @@ -91,7 +92,7 @@ class FoodPlugin @Inject constructor( repository.runTransactionForResult(SyncNsFoodTransaction(food)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -101,7 +102,7 @@ class FoodPlugin @Inject constructor( } } else { aapsLogger.error(LTag.DATABASE, "Error parsing food", jsonFood.toString()) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to "Error parsing food")) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 8264e8ed63..ae90713332 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context +import androidx.work.Data import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -52,10 +54,10 @@ class NSClientAddUpdateWorker( override fun doWork(): Result { val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT - if (!acceptNSData) return Result.failure() + if (!acceptNSData) return Result.success() val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) var ret = Result.success() var latestDateInReceivedData = 0L @@ -81,7 +83,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -105,7 +107,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsCarbsTransaction(carb)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -131,7 +133,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -175,7 +177,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt index a2639ddd45..8ba3813be2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -36,14 +37,14 @@ class NSClientMbgWorker( if (!acceptNSData) return ret val mbgArray = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) for (i in 0 until mbgArray.length()) { val nsMbg = NSMbg(mbgArray.getJSONObject(i)) if (!nsMbg.isValid()) continue repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEventFromNsMbg(nsMbg))) .doOnError { aapsLogger.error("Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt index 2c932dc086..0687be4f52 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -48,12 +49,12 @@ class NSClientRemoveWorker( override fun doWork(): Result { val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT - if (!acceptNSData) return Result.failure() + if (!acceptNSData) return Result.success() var ret = Result.success() val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) for (i in 0 until treatments.length()) { val json = treatments.getJSONObject(i) @@ -64,7 +65,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -84,7 +85,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -101,7 +102,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -118,7 +119,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsCarbsTransaction(carbs)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 49d7a813bf..15e5825901 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -9,6 +9,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants @@ -180,8 +181,8 @@ class SmsCommunicatorPlugin @Inject constructor( @Suppress("SpellCheckingInspection") override fun doWork(): Result { val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() - val format = bundle.getString("format") ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) + val format = bundle.getString("format") ?: return Result.failure(workDataOf("Error" to "missing format in input data")) val pdus = bundle["pdus"] as Array<*> for (pdu in pdus) { val message = SmsMessage.createFromPdu(pdu as ByteArray, format) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index e2c3c56608..15ca109728 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.profile.ns import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -96,7 +97,7 @@ class NSProfilePlugin @Inject constructor( override fun doWork(): Result { val profileString = dataWorker.pickupJSONObject(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) nsProfilePlugin.profile = ProfileStore(injector, profileString) nsProfilePlugin.storeNSProfile() if (nsProfilePlugin.isEnabled()) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 2c6a331fac..1614a1aa61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -6,6 +6,7 @@ import android.content.pm.PackageManager import androidx.core.content.ContextCompat import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -97,9 +98,9 @@ class DexcomPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) try { val sourceSensor = when (bundle.getString("sensorType") ?: "") { "G6" -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE @@ -107,7 +108,7 @@ class DexcomPlugin @Inject constructor( else -> GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN } val glucoseValuesBundle = bundle.getBundle("glucoseValues") - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing glucoseValues")) val glucoseValues = mutableListOf() for (i in 0 until glucoseValuesBundle.size()) { val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!! @@ -144,7 +145,7 @@ class DexcomPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -161,7 +162,7 @@ class DexcomPlugin @Inject constructor( } } catch (e: Exception) { aapsLogger.error("Error while processing intent from Dexcom App", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } return ret } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 0a5fbeb500..876fe8d0db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -68,9 +69,9 @@ class EversensePlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase")) if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) @@ -111,7 +112,7 @@ class EversensePlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -141,7 +142,7 @@ class EversensePlugin @Inject constructor( )) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index 8d5bcaa0ea..e6e6fa9c7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -55,7 +56,7 @@ class GlimpPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}") val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( @@ -69,7 +70,7 @@ class GlimpPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Glimp App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 0ecd4cde17..bf0c30e899 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -60,8 +61,8 @@ class MM640gPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() - val collection = inputData.getString("collection") ?: return Result.failure() + if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() + val collection = inputData.getString("collection") ?: return Result.failure(workDataOf("Error" to "missing collection")) if (collection == "entries") { val data = inputData.getString("data") aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data") @@ -87,7 +88,7 @@ class MM640gPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -98,7 +99,7 @@ class MM640gPlugin @Inject constructor( } } catch (e: JSONException) { aapsLogger.error("Exception: ", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 78f4f8f774..734bec03f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -117,7 +118,7 @@ class NSClientSourcePlugin @Inject constructor( if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_autobackfill, true) && !dexcomPlugin.isEnabled()) return Result.success() val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) try { var latestDateInReceivedData: Long = 0 @@ -141,7 +142,7 @@ class NSClientSourcePlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null, !nsClientSourcePlugin.isEnabled())) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from NSClient App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -158,7 +159,7 @@ class NSClientSourcePlugin @Inject constructor( } } catch (e: Exception) { aapsLogger.error("Unhandled exception", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } // Objectives 0 sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 9ada30986c..b003adc13e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R @@ -59,7 +60,7 @@ class PoctechPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData") try { val glucoseValues = mutableListOf() @@ -80,7 +81,7 @@ class PoctechPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Poctech App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -91,7 +92,7 @@ class PoctechPlugin @Inject constructor( } } catch (e: JSONException) { aapsLogger.error("Exception: ", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } return ret } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index ce38a5e97e..92a92e7ef2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -60,7 +61,7 @@ class TomatoPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0), @@ -73,7 +74,7 @@ class TomatoPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Tomato App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index f07d64b876..bf5aa0b1d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -72,9 +73,9 @@ class XdripPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle") val glucoseValues = mutableListOf() @@ -90,7 +91,7 @@ class XdripPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Xdrip", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues ->