> ## Documentation Index
> Fetch the complete documentation index at: https://developer.suki.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Suki Error Reference

> SukiError type represents the structure for SDK errors

SukiError type represents the structure for SDK errors. The code snippet below shows how to use the `SukiError` type to create a suki error object.

```js JavaScript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
type SukiError = {
  code: ErrorCode;
  details: ErrorDetail;
};
```

## Properties

<Expandable title="properties" defaultOpen="true">
  <ResponseField name="code" type="ErrorCode" href="/web-sdk/api-reference/types/suki-error#errorcode-identifier">
    Unique error code identifier
  </ResponseField>

  <ResponseField name="details" type="ErrorDetail" href="/web-sdk/api-reference/types/suki-error#errordetail">
    Detailed error information including name, message, and reason
  </ResponseField>
</Expandable>

## ErrorCode identifier

ErrorCode represents the unique identifiers for different types of SDK errors. The following table lists the available error code identifiers and their descriptions.

| Code       | Name                      | Category       | Description                                          |
| ---------- | ------------------------- | -------------- | ---------------------------------------------------- |
| `SUKI0001` | init:sdk-init-failed      | Initialization | SDK initialization failed                            |
| `SUKI0002` | init:auth-failed          | Authentication | User authentication failed                           |
| `SUKI0003` | init:mount-failed         | Initialization | SDK mounting to DOM failed                           |
| `SUKI0004` | init:messenger-failed     | Initialization | Internal messaging system failed                     |
| `SUKI0005` | init:invalid-options      | Initialization | Invalid initialization options provided              |
| `SUKI0006` | navigate:failed           | Navigation     | Navigation within SDK failed                         |
| `SUKI0007` | create-appointment:failed | Encounter      | Failed to create appointment/encounter               |
| `SUKI0008` | get-appointment:failed    | Encounter      | Failed to retrieve appointment/encounter             |
| `SUKI0009` | create-patient:failed     | Patient        | Failed to create patient record                      |
| `SUKI0010` | update-patient:failed     | Patient        | Failed to update patient information                 |
| `SUKI0011` | get-patient:failed        | Patient        | Failed to retrieve patient information               |
| `SUKI0012` | note-submission:failed    | Notes          | Failed to submit clinical note                       |
| `SUKI0013` | ambient-fail              | Ambient        | Ambient session operation failed                     |
| `SUKI0014` | encounter-fail            | Encounter      | General encounter operation failed                   |
| `SUKI0015` | token-update-fail         | Authentication | Failed to update `partnerToken`                      |
| `SUKI0016` | unsupported-loinc-codes   | Configuration  | Provided LOINC codes are not supported               |
| `SUKI0017` | no-supported-loinc-codes  | Configuration  | No supported LOINC codes found in configuration      |
| `SUKI0018` | multiple-pbn-sections     | Configuration  | Multiple sections marked as PBN (Problem-Based Note) |

## ErrorDetail

ErrorDetail represents the detailed information about a specific error. The code snippet below shows how to use the `ErrorDetail` type to create an error detail object.

```js JavaScript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
type ErrorDetail = {
  name: `init:sdk-init-failed` | `init:auth-failed` ...;
  message: string;
  reason?: ErrorReasons;
}
```

### ErrorDetail properties

<Expandable title="properties" defaultOpen="true">
  <ResponseField name="name" type="string" required>
    Unique name for the error (corresponds to error code)
  </ResponseField>

  <ResponseField name="message" type="string" required>
    Human-readable description of the error
  </ResponseField>

  <ResponseField name="reason" type="ErrorReasons" href="/web-sdk/api-reference/types/suki-error#errorreasons">
    Additional context about why the error occurred
  </ResponseField>
</Expandable>

## ErrorReasons

ErrorReasons represents the specific reasons that provide additional context for why an error occurred.

```js JavaScript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
type ErrorReasons =
  | "lib-error"
  | "no-init"
  | "no-partner-token"
  | "missing-partner-details"
  | "no-init-or-auth"
  | "service-error"
  | "already-started"
  | "no-ambient"
  | "ambient-in-progress"
  | "invalid-encounter"
  | "unsupported-loinc-codes"
  | "no-supported-loinc-codes"
  | "multiple-pbn-sections";
```

The below table lists the available error reasons and their descriptions.

| Reason                       | Category       | Description                                                                                                                                                    |
| ---------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **already-started**          | State          | Operation attempted when already in progress                                                                                                                   |
| **ambient-in-progress**      | Ambient        | Cannot perform action while ambient session is active                                                                                                          |
| **invalid-encounter**        | Data           | Encounter data is invalid or malformed (for example **`patient.identifier`** or **`encounter.identifier`** longer than **36 characters** or otherwise invalid) |
| **lib-error**                | System         | Internal library or system error                                                                                                                               |
| **missing-partner-details**  | Configuration  | Required partner authentication details are missing                                                                                                            |
| **multiple-pbn-sections**    | Configuration  | Multiple sections marked as PBN when only one is allowed                                                                                                       |
| **no-ambient**               | State          | No ambient session available for operation                                                                                                                     |
| **no-init**                  | State          | SDK not initialized before operation attempted                                                                                                                 |
| **no-init-or-auth**          | Authentication | SDK not initialized or user not authenticated                                                                                                                  |
| **no-partner-token**         | Authentication | Partner token is missing or invalid                                                                                                                            |
| **no-supported-loinc-codes** | Configuration  | No supported LOINC codes found                                                                                                                                 |
| **service-error**            | Network        | External service or API error                                                                                                                                  |
| **unsupported-loinc-codes**  | Configuration  | Provided LOINC codes are not supported                                                                                                                         |

## Example

```js JavaScript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
const error = {
  code: "SUKI0001",
  details: {
    name: "init:sdk-init-failed",
    message: "SDK initialization failed",
    reason: "lib-error"
  }
};
```
