Skip to content

Commit

Permalink
Merge pull request #446 from ps2/new-pump-history-fix
Browse files Browse the repository at this point in the history
Handle pageDoesNotExist error from pump during history fetching
  • Loading branch information
ps2 authored Sep 2, 2018
2 parents 80f554a + c63afb5 commit 943c820
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions MinimedKit/Messages/PumpErrorMessageBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum PumpErrorCode: UInt8, CustomStringConvertible {
case commandRefused = 0x08
case maxSettingExceeded = 0x09
case bolusInProgress = 0x0c
case pageDoesNotExist = 0x0d

public var description: String {
switch self {
Expand All @@ -22,6 +23,8 @@ public enum PumpErrorCode: UInt8, CustomStringConvertible {
return LocalizedString("Max setting exceeded", comment: "Pump error code describing max setting exceeded")
case .bolusInProgress:
return LocalizedString("Bolus in progress", comment: "Pump error code when bolus is in progress")
case .pageDoesNotExist:
return LocalizedString("History page does not exist", comment: "Pump error code when invalid history page is requested")
}
}

Expand Down
7 changes: 5 additions & 2 deletions RileyLinkKit/PumpOpsSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,11 @@ extension PumpOpsSession {

do {
pageData = try getHistoryPage(pageNum)
} catch PumpOpsError.pumpError {
break pages
} catch PumpCommandError.arguments(let error) {
if case PumpOpsError.pumpError(.pageDoesNotExist) = error {
return (events, pumpModel)
}
throw PumpCommandError.arguments(error)
}

var idx = 0
Expand Down

0 comments on commit 943c820

Please sign in to comment.