IobError.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import Foundation
  2. enum IobError: LocalizedError, Equatable {
  3. case tempBasalDurationMismatch
  4. case tempBasalMissingDuration(timestamp: Date)
  5. case tempBasalDurationMissingDuration(timestamp: Date)
  6. case pumpSuspendResumeMismatch
  7. case basalRateNotSet
  8. case rateNotSetOnTempBasal(timestamp: Date)
  9. case bilinearCurveNotSupported
  10. case diaNotSet
  11. var errorDescription: String? {
  12. switch self {
  13. case .tempBasalDurationMismatch:
  14. return "Incomplete temp basal / duration pair"
  15. case let .tempBasalMissingDuration(timestamp):
  16. return "Temp basal is missing duration @ \(timestamp)"
  17. case let .tempBasalDurationMissingDuration(timestamp):
  18. return "Temp basal duration @ \(timestamp) pump history entry without a duration set"
  19. case .pumpSuspendResumeMismatch:
  20. return "Had two consecutive pump suspend or resume events"
  21. case .basalRateNotSet:
  22. return "Unable to derive the current basal rate from the profile data"
  23. case let .rateNotSetOnTempBasal(timestamp):
  24. return "Temp basal @ \(timestamp) without a rate set"
  25. case .bilinearCurveNotSupported:
  26. return "Bilinear curve not supported in Trio"
  27. case .diaNotSet:
  28. return "DIA not set on Profile"
  29. }
  30. }
  31. }