I can answer this myself. After the introduction of the concurrency in Swift, the HKStatisticsCollectionQueryDescriptor seems the method to use. Completion statement and HKStatisticsCollectionQuery is dated and harder to implement.
Post
Replies
Boosts
Views
Activity
I will answer this myself.
Solution 1 is to throw fatalError in the
case .errorDatabaseInaccessible:
statement. This will shutdown the app. But it is not a desirable solution as really forces a crash.
Solution 2 is the reprogram the setup to use HKStatisticsCollectionQueryDescriptor and concurrency instead of completion and statisticsUpdateHandler.
Wrapping a "for try await" in a repeat and do loop it is possible to catch errors from the try statement and continue the execution in the repeat loop with a continue statement.