<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKError",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:SC11HKErrorCodeLeV"
  },
  "title" : "HKError"
}
-->

# HKError

An error returned from a HealthKit method.

```
struct HKError
```

## Topics

### Accessing errors

[`Code`](/documentation/HealthKit/HKError/Code)

Error codes returned by HealthKit.

[`noError`](/documentation/HealthKit/HKError/noError)

No error occurred.

[`errorHealthDataUnavailable`](/documentation/HealthKit/HKError/errorHealthDataUnavailable)

The user accessed HealthKit on an unsupported device.

[`errorHealthDataRestricted`](/documentation/HealthKit/HKError/errorHealthDataRestricted)

A Mobile Device Management (MDM) profile restricts the use of HealthKit on this device.

[`errorInvalidArgument`](/documentation/HealthKit/HKError/errorInvalidArgument)

The app passed an invalid argument to the HealthKit API.

[`errorAuthorizationDenied`](/documentation/HealthKit/HKError/errorAuthorizationDenied)

The user hasn’t given the app permission to save data.

[`errorAuthorizationNotDetermined`](/documentation/HealthKit/HKError/errorAuthorizationNotDetermined)

The app hasn’t yet asked the user for the authorization required to complete the task.

[`errorRequiredAuthorizationDenied`](/documentation/HealthKit/HKError/errorRequiredAuthorizationDenied)

The user hasn’t granted the application authorization to access all the required clinical record types.

[`errorDatabaseInaccessible`](/documentation/HealthKit/HKError/errorDatabaseInaccessible)

The HealthKit data is unavailable because it’s protected and the device is locked.

[`errorUserCanceled`](/documentation/HealthKit/HKError/errorUserCanceled)

The user canceled the operation.

[`errorAnotherWorkoutSessionStarted`](/documentation/HealthKit/HKError/errorAnotherWorkoutSessionStarted)

Another app started a workout session.

[`errorUserExitedWorkoutSession`](/documentation/HealthKit/HKError/errorUserExitedWorkoutSession)

The user exited your application while a workout session was running.

[`errorNoData`](/documentation/HealthKit/HKError/errorNoData)

Data is unavailable for the requested query and predicate.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Error`](/documentation/Swift/Error)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomNSError`](/documentation/Foundation/CustomNSError)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)