Skip to content

Commit

Permalink
Add more information to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
gestrich committed Aug 9, 2024
1 parent 699a7cf commit 14302ad
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,22 @@ public struct TimelineProviderShared {
}
let loopers = try composer.accountServiceManager.getLoopers()
guard let looper = loopers.first(where: { $0.id == looperID || $0.name == looperName }) else {
throw TimelineProviderError.looperNotFound(looperID)
throw TimelineProviderError.looperNotFound(looperID, looperName ?? "", loopers.count)
}

return looper
}

private enum TimelineProviderError: LocalizedError {
case looperNotFound(String)
case looperNotFound(_ looperID: String, _ looperName: String, _ availableCount: Int)
case looperNotConfigured
case notReady
case missingGlucose

var errorDescription: String? {
switch self {
case .looperNotFound(let looperID):
return "The looper for this widget was not found (\(looperID)). " + configurationText()
case let .looperNotFound(looperID, looperName, availableCount):
return "The looper for this widget was not found: \(looperName), (\(looperID)) \(availableCount)." + configurationText()
case .looperNotConfigured:
return "No looper is configured for this widget. " + configurationText()
case .notReady:
Expand Down

0 comments on commit 14302ad

Please sign in to comment.