> For the complete documentation index, see [llms.txt](https://cramiumlabs.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cramiumlabs.gitbook.io/docs/feature-list/error-code-system.md).

# Error code system

### Format

Error codes follow this format: `[cra]-[gms]-[000]-[00]`

Where:

* `cra`: Unique prefix for easy identification
* `gms`: 3-letter module/SDK identifier
* `000`: 3-digit error type
* `00`: 2-digit specific error code

### Module/SDK Identifiers

* `gms`: Go Mobile SDK
* `mss`: Mobile Swift SDK (iOS)
* `mks`: Mobile Kotlin SDK (Android)
* `mfs`: Mobile Flutter SDK
* `mcl`: MPC Core Library
* `bcl`: Blockchain Core Library
* `ctl`: Cramium TSS Library

### Error Types and Codes

#### General Errors (000)

| Code   | Description               |
| ------ | ------------------------- |
| 000-00 | Client is not initialized |
| 000-01 | Token expired             |
| 000-99 | Unknown error             |

#### Passkey Errors (001)

| Code   | Description                 |
| ------ | --------------------------- |
| 001-00 | User name must not be empty |
| 001-01 | Cannot authenticate user    |
| 001-02 | Cannot register user        |
| 001-03 | User cancel operation       |
| 001-04 | Don't have permission       |
| 001-05 | Verification failed         |
| 001-99 | Unknown error               |

#### Network Interaction Errors (002)

| Code   | Description                                       |
| ------ | ------------------------------------------------- |
| 002-00 | No internet connection                            |
| 002-01 | Cannot connect                                    |
| 002-02 | Request timeout                                   |
| 002-03 | Bad request (status 400)                          |
| 002-04 | Not found (status 404)                            |
| 002-05 | Other server error code (not 200-299, 400 or 404) |
| 002-06 | Unknown server response                           |
| 002-07 | Cannot encode data (client side)                  |
| 002-08 | Cannot decode data (client side)                  |
| 002-99 | Unknown error                                     |

#### Whitelist Errors (003)

| Code   | Description                                                                |
| ------ | -------------------------------------------------------------------------- |
| 003-00 | White list repository is not initialized                                   |
| 003-01 | Address already exist                                                      |
| 003-02 | Address not in whitelist (build/send)                                      |
| 003-03 | Amount is not allowed                                                      |
| 003-04 | Per transaction limit is larger than global per transaction limit          |
| 003-05 | Per transaction limit is larger than global daily limit                    |
| 003-06 | Per transaction limit is larger than daily limit                           |
| 003-07 | Daily limit is larger than global daily limit                              |
| 003-08 | Global per transaction limit is smaller than address per transaction limit |
| 003-99 | Unknown error                                                              |

#### Backup Errors (004)

| Code   | Description                                             |
| ------ | ------------------------------------------------------- |
| 004-00 | File not found                                          |
| 004-01 | Shard/Server shard broken ("Group id → detail message") |
| 004-02 | Backup key not found                                    |
| 004-03 | Backup file is empty                                    |
| 004-04 | Can't decrypt backup file                               |
| 004-05 | Can't encrypt backup file                               |
| 004-06 | Paillier group not found                                |
| 004-07 | Group ID not found                                      |
| 004-08 | Request data for callback method is not found           |
| 004-09 | Fail to generate sek                                    |

#### Cloud Service Errors (005)

| Code   | Description                      |
| ------ | -------------------------------- |
| 005-00 | User/Account not found           |
| 005-01 | User cancel operation            |
| 005-02 | Don't have permission            |
| 005-03 | Fail to store backup to cloud    |
| 005-04 | Fail to get backup from cloud    |
| 005-05 | Fail to delete backup from cloud |
| 005-06 | Unavailable                      |
| 005-07 | Timeout                          |

#### Secure Storage Errors (006)

| Code   | Description                                          |
| ------ | ---------------------------------------------------- |
| 006-00 | An error occurred while writing to secure storage    |
| 006-01 | An error occurred while reading from secure storage  |
| 006-02 | An error occurred while deleting from secure storage |

#### UDM Errors (007)

| Code   | Description               |
| ------ | ------------------------- |
| 007-00 | Can't get IMEI for device |
| 007-99 | Unknown error             |

### Platform-Specific Error Codes

#### iOS (cra-mss)

| Type | Description  | Detail Error                                                                 |
| ---- | ------------ | ---------------------------------------------------------------------------- |
| 000  | General      | <p>00: Client is not initialized<br>99: Unknown error</p>                    |
| 001  | iOS Specific | <p>00: Cannot decode request - details: method name<br>99: Unknown error</p> |

#### Android (cra-mks)

| Type | Description      | Detail Error                                              |
| ---- | ---------------- | --------------------------------------------------------- |
| 000  | General          | <p>00: Client is not initialized<br>99: Unknown error</p> |
| 002  | Android Specific | <p>00: Cannot decode request<br>99: Unknown error</p>     |

#### Flutter (cra-mfs)

| Type | Description | Detail Error                                              |
| ---- | ----------- | --------------------------------------------------------- |
| 000  | General     | <p>00: Client is not initialized<br>99: Unknown error</p> |

### GoSDK Errors (cra-gms)

| Type | Description | Detail Error                                              |
| ---- | ----------- | --------------------------------------------------------- |
| 000  | General     | <p>00: Client is not initialized<br>99: Unknown error</p> |

### Usage Examples

#### iOS Example

```swift
do {
    // Some operation
} catch let error as MpcException {
    switch error.code {
    case "cra-mss-000-00":
        print("Client is not initialized")
    case "cra-mss-001-00":
        print("Cannot decode request")
    default:
        print("Unknown error: \(error.message)")
    }
}
```

#### Android Example

```kotlin
try {
    // Some operation
} catch (e: MpcException) {
    when (e.code) {
        "cra-mks-000-00" -> println("Client is not initialized")
        "cra-mks-002-00" -> println("Cannot decode request")
        else -> println("Unknown error: ${e.message}")
    }
}
```

#### Flutter Example

```dart
try {
    // Some operation
} catch (e) {
    if (e is MpcException) {
        switch (e.code) {
            case "cra-mfs-000-00":
                print("Client is not initialized");
                break;
            default:
                print("Unknown error: ${e.message}");
        }
    }
}
```
