# TryYourSizeError

> Every error the SDK raises: a stable code, a message and a doc link (like the web SDK).

Source: https://docs.tryyoursize.com/reference/ios/errors/

*Type* · `TryYourSize (Swift)`

Every error the SDK raises: a stable `code`, a message and a doc link (like the web SDK).

Each error has a stable `code`, a `message` and a `docURL`. Explanations: [Mobile SDK errors](https://docs.tryyoursize.com/mobile/errors.md).

## Codes

- **`.secretKeyInApp`** (`"secret_key_in_app"`, optional): A secret (`sk_`) or restricted (`rk_`) key was passed. Those belong on your server.
- **`.invalidKey`** (`"invalid_key"`, optional): Not a publishable key (`pk_test_…` / `pk_live_…`).
- **`.invalidAppIdentifier`** (`"invalid_app_identifier"`, optional): The bundle identifier can't be used as an app origin.
- **`.invalidOption`** (`"invalid_option"`, optional)
- **`.windowUnreachable`** (`"window_unreachable"`, optional): Our window did not answer (offline, or blocked).
- **`.appNotAllowed`** (`"app_not_allowed"`, optional): This app (`ios-app://<bundle id>`) is not registered for the key's store.
- **`.signInCancelled`** (`"sign_in_cancelled"`, optional)
- **`.signInUnavailable`** (`"sign_in_unavailable"`, optional): System-browser sign-in is not available yet.

## Example

**Swift**

```swift
do {
    tys = try TryYourSize(publishableKey: key)
} catch let error as TryYourSizeError where error.code == .secretKeyInApp {
    assertionFailure("Use the pk_ key in the app")
}
```
