ProfileError.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import Foundation
  2. enum ProfileError: LocalizedError, Equatable {
  3. case invalidDIA(value: Decimal)
  4. case invalidCurrentBasal(value: Decimal?)
  5. case invalidMaxDailyBasal(value: Decimal?)
  6. case invalidMaxBasal(value: Decimal?)
  7. case invalidISF(value: Decimal?)
  8. case invalidCarbRatio
  9. case invalidBgTargets
  10. case invalidCalendar
  11. var errorDescription: String? {
  12. switch self {
  13. case let .invalidDIA(value):
  14. return "DIA of \(String(describing: value)) is not supported (must be > 1)"
  15. case let .invalidCurrentBasal(value):
  16. return "Current basal of \(String(describing: value)) is not supported (must be > 0)"
  17. case let .invalidMaxDailyBasal(value):
  18. return "Max daily basal of \(String(describing: value)) is not supported (must be > 0)"
  19. case let .invalidMaxBasal(value):
  20. return "Max basal of \(String(describing: value)) is not supported (must be >= 0.1)"
  21. case let .invalidISF(value):
  22. return "ISF of \(String(describing: value)) is not supported (must be >= 5)"
  23. case .invalidCarbRatio:
  24. return "Profile wasn't given carb ratio data, cannot calculate carb_ratio"
  25. case .invalidBgTargets:
  26. return "Profile wasn't given bg target data"
  27. case .invalidCalendar:
  28. return "Unable to extract hours and minutes from the current calendar"
  29. }
  30. }
  31. }