From 0b75bbf85f781429af802d81422f15880ac4a516 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Wed, 9 Sep 2020 18:40:35 +0200 Subject: [PATCH] Provide clear error messages when no basal profile is active --- .../omnipod/manager/AapsOmnipodManager.java | 17 +++++++++++++++-- omnipod/src/main/res/values/strings.xml | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index 97a2123d76..b8e06fd07e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -162,7 +162,14 @@ public class AapsOmnipodManager { public PumpEnactResult setInitialBasalScheduleAndInsertCannula(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile) { if (podInitActionType != PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP) { - return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name())); + String comment = getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name()); + podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); + return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + } + if (profile == null) { + String comment = getStringResource(R.string.omnipod_error_set_initial_basal_schedule_no_profile); + podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); + return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); } try { @@ -233,6 +240,12 @@ public class AapsOmnipodManager { } public PumpEnactResult setBasalProfile(Profile profile) { + if (profile == null) { + String comment = getStringResource(R.string.omnipod_error_failed_to_set_profile_empty_profile); + showNotification(Notification.FAILED_UDPATE_PROFILE, comment, Notification.URGENT, R.raw.boluserror); + return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + } + PodHistoryEntryType historyEntryType = podStateManager.isSuspended() ? PodHistoryEntryType.RESUME_DELIVERY : PodHistoryEntryType.SET_BASAL_SCHEDULE; try { @@ -761,7 +774,7 @@ public class AapsOmnipodManager { } aapsLogger.error(LTag.PUMP, String.format("Caught OmnipodException[certainFailure=%s] from OmnipodManager (user-friendly error message: %s)", ((OmnipodException) ex).isCertainFailure(), comment), ex); } else { - comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName()); + comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName(), ex.getMessage()); aapsLogger.error(LTag.PUMP, String.format("Caught unexpected exception type[certainFailure=false] from OmnipodManager (user-friendly error message: %s)", comment), ex); } diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 73b3871bae..47d006afa9 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -69,7 +69,7 @@ Illegal PodInitActionType: %1$s No active Pod Command verification failed - An unexpected error occurred. Please report! (type: %1$s). + An unexpected error occurred. Please report! (%1$s: %2$s). Communication failed: received invalid input parameters Communication failed: timeout Communication failed: an unexpected error occurred. Please report! @@ -190,6 +190,8 @@ Source Date Type: + Failed to set basal profile: received an empty profile. Make sure to activate your basal profile. + No basal profile is active. Make sure to activate your basal profile. %1$d minute