You must call the completion handler block in every case in your update handler.
In line 6, you handle the error without ever calling the completion handler block. Users who hit this error case will fail to tell the system that you are 'done'. This will eventually result in the system stop sending you background updates.
See the discuss here: https://developer.apple.com/documentation/healthkit/hkobserverquerycompletionhandler
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags: