---
title: HKError.Code
framework: healthkit
role: symbol
role_heading: Enumeration
path: healthkit/hkerror/code
---

# HKError.Code

Error codes returned by HealthKit.

## Declaration

```swift
enum Code
```

## Mentioned in

Executing Statistics Collection Queries

## Topics

### Errors

- [HKError.Code.errorHealthDataUnavailable](healthkit/hkerror/code/errorhealthdataunavailable.md)
- [HKError.Code.errorHealthDataRestricted](healthkit/hkerror/code/errorhealthdatarestricted.md)
- [HKError.Code.errorInvalidArgument](healthkit/hkerror/code/errorinvalidargument.md)
- [HKError.Code.errorAuthorizationDenied](healthkit/hkerror/code/errorauthorizationdenied.md)
- [HKError.Code.errorAuthorizationNotDetermined](healthkit/hkerror/code/errorauthorizationnotdetermined.md)
- [HKError.Code.errorRequiredAuthorizationDenied](healthkit/hkerror/code/errorrequiredauthorizationdenied.md)
- [HKError.Code.errorDatabaseInaccessible](healthkit/hkerror/code/errordatabaseinaccessible.md)
- [HKError.Code.errorUserCanceled](healthkit/hkerror/code/errorusercanceled.md)
- [HKError.Code.errorAnotherWorkoutSessionStarted](healthkit/hkerror/code/erroranotherworkoutsessionstarted.md)
- [HKError.Code.errorUserExitedWorkoutSession](healthkit/hkerror/code/erroruserexitedworkoutsession.md)
- [HKError.Code.errorNoData](healthkit/hkerror/code/errornodata.md)

### Enumeration Cases

- [HKError.Code.errorBackgroundWorkoutSessionNotAllowed](healthkit/hkerror/code/errorbackgroundworkoutsessionnotallowed.md)
- [HKError.Code.errorDataSizeExceeded](healthkit/hkerror/code/errordatasizeexceeded.md)
- [HKError.Code.errorNotPermissibleForGuestUserMode](healthkit/hkerror/code/errornotpermissibleforguestusermode.md)
- [HKError.Code.errorWorkoutActivityNotAllowed](healthkit/hkerror/code/errorworkoutactivitynotallowed.md)
- [HKError.Code.unknownError](healthkit/hkerror/code/unknownerror.md)

### Initializers

- [init(rawValue:)](healthkit/hkerror/code/init(rawvalue:).md)

### Type Properties

- [noError](healthkit/hkerror/code/noerror.md)

## Relationships

### Conforms To

- [BitwiseCopyable](swift/bitwisecopyable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [RawRepresentable](swift/rawrepresentable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Errors

- [HKError](healthkit/hkerror.md)
- [HKErrorDomain](healthkit/hkerrordomain.md)
