Merge pull request #14 from samspycher/tbr_duration_validation

throw IllegalArgumentException for zero or negative durations
This commit is contained in:
bartsopers 2020-10-07 17:05:32 +02:00 committed by GitHub
commit 47f94ce2d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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");
}