From 3a6d1f286c823f85627b1174ff8e452f4fd64dfc Mon Sep 17 00:00:00 2001 From: Sam Spycher Date: Mon, 5 Oct 2020 13:45:13 +0200 Subject: [PATCH] throw IllegalArgumentException for zero or negative durations --- .../communication/message/command/TempBasalExtraCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java index baac0f9305..8f5cf5053b 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java @@ -27,7 +27,10 @@ public class TempBasalExtraCommand extends MessageBlock { } else if (rate > OmnipodConstants.MAX_BASAL_RATE) { throw new IllegalArgumentException("Rate exceeds max basal rate"); } - if (duration.isLongerThan(OmnipodConstants.MAX_TEMP_BASAL_DURATION)) { + + if (duration.isShorterThan(Duration.ZERO) || duration.equals(Duration.ZERO)) { + throw new IllegalArgumentException("Duration should be > 0"); + } else if (duration.isLongerThan(OmnipodConstants.MAX_TEMP_BASAL_DURATION)) { throw new IllegalArgumentException("Duration exceeds max temp basal duration"); }