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

# C++ results and errors

> Check factory results, move owned values and interpret every SDK error.

C++ wrapper **0.24.0**, core **0.24.0**, C++11 or newer. Include `aic.hpp` and link the matching wrapper/native libraries. Start with the [C++ integration guide](/reference/sdk/language-bindings/cpp).

All names below are in namespace `aic`. Check [Result and error handling](/reference/sdk/api/cpp/results-and-errors) before extracting a factory result. Ordinary C++ allocation or string operations can still throw; SDK status failures use the declared return values.

<span id="aic-Result-T" />

## `aic::Result<T>`

`Result<T>` stores an ordinary value and a status. It does not throw on SDK errors, check access or automatically unwrap. `take()` moves the stored value regardless of the error code. Always call `ok()` or inspect `error` before extraction.

<span id="aic-Result-T-value" />

<span id="aic-Result-T-error" />

| Public field | Type        | Meaning                                                                                |
| ------------ | ----------- | -------------------------------------------------------------------------------------- |
| `value`      | `T`         | Stored success value, or the factory's failure placeholder. Never use a failed handle. |
| `error`      | `ErrorCode` | Operation status. `Success` is zero.                                                   |

<span id="aic-Result-T-Result-copy" />

### `aic::Result<T>::Result-copy`

```cpp theme={null}
Result(const T& v, ErrorCode e);
```

Copies `v` and stores `e`. This overload requires `T` to be copyable when instantiated; it cannot copy an SDK-owned move-only handle. It performs no validation.

<span id="aic-Result-T-Result-move" />

### `aic::Result<T>::Result-move`

```cpp theme={null}
Result(T&& v, ErrorCode e);
```

Moves `v` into the result and stores `e`. Use it for move-only handles. It performs no validation. There is no default constructor.

<span id="aic-Result-T-ok" />

### `aic::Result<T>::ok`

```cpp theme={null}
bool ok() const;
```

Returns `error == ErrorCode::Success` without inspecting the stored object.

<span id="aic-Result-T-take" />

### `aic::Result<T>::take`

```cpp theme={null}
T take();
```

Returns `std::move(value)` without checking `error` and without resetting it. Extract a successful owned handle once. After extraction, the original handle value is moved-from; it can be destroyed or assigned, but must not be used to process or query audio state.

## Checked extraction

This complete credential-free program checks the model-loading result before extracting the model and printing the linked core version. A missing file prints the error code and exits with status 1. Link it as described in the [C++ guide](/reference/sdk/language-bindings/cpp).

```cpp theme={null}
#include "aic.hpp"
#include <iostream>

int main() {
    auto result = aic::Model::create_from_file("path/to/model.aicmodel");
    if (!result.ok()) {
        std::cerr << "Model load failed: " << static_cast<int>(result.error) << '\n';
        return 1;
    }
    auto model = result.take();
    std::cout << model.get_id() << " with core " << aic::get_sdk_version() << '\n';
}
```

## Getter assertions

Model metadata getters and context value/decision/delay getters return scalar values and assert the underlying C call succeeded. They are not checked `Result` APIs. In assertion-disabled builds, a failure returns the wrapper's initialized fallback (zero or false). Use valid objects and enum members; do not treat fallback values as error reporting. `Model::get_id()` separately returns an empty string for a null native handle.

<span id="aic-ErrorCode" />

## `aic::ErrorCode`

`enum class ErrorCode : int` maps directly to the C status values. The following list is complete for wrapper 0.24.0.

<span id="aic-ErrorCode-Success" />

<span id="aic-ErrorCode-NullPointer" />

<span id="aic-ErrorCode-ParameterOutOfRange" />

<span id="aic-ErrorCode-NotInitialized" />

<span id="aic-ErrorCode-AudioConfigUnsupported" />

<span id="aic-ErrorCode-AudioConfigMismatch" />

<span id="aic-ErrorCode-ProcessingNotAllowed" />

<span id="aic-ErrorCode-InternalError" />

<span id="aic-ErrorCode-LicenseFormatInvalid" />

<span id="aic-ErrorCode-LicenseVersionUnsupported" />

<span id="aic-ErrorCode-LicenseExpired" />

<span id="aic-ErrorCode-TokenUpdateUnsupported" />

<span id="aic-ErrorCode-ModelInvalid" />

<span id="aic-ErrorCode-ModelVersionUnsupported" />

<span id="aic-ErrorCode-FilePathInvalid" />

<span id="aic-ErrorCode-FileSystemError" />

<span id="aic-ErrorCode-ModelDataUnaligned" />

<span id="aic-ErrorCode-ModelTypeUnsupported" />

| Member                                 | Value | Meaning and recovery                                                                                                                     |
| -------------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `ErrorCode::Success`                   | 0     | The operation succeeded. A returned result value can be used.                                                                            |
| `ErrorCode::NullPointer`               | 1     | A required native pointer is null. Use valid handles and buffers; do not use a moved-from handle.                                        |
| `ErrorCode::ParameterOutOfRange`       | 2     | A parameter is outside its accepted range or is NaN. Check the parameter bounds before setting it.                                       |
| `ErrorCode::NotInitialized`            | 3     | The processor, VAD or collector has not been initialized. Call its `initialize` method successfully before supplying audio.              |
| `ErrorCode::AudioConfigUnsupported`    | 4     | The sample rate or block configuration is unsupported. Use a positive block size and settings supported by the model.                    |
| `ErrorCode::AudioConfigMismatch`       | 5     | The audio length violates the configured fixed block size or variable maximum. Correct the buffer length.                                |
| `ErrorCode::ProcessingNotAllowed`      | 6     | The session disallows processing. Check credentials, network access and session state, and apply your application's audio fallback.      |
| `ErrorCode::InternalError`             | 7     | An internal operation failed. If valid input reproduces the failure, contact support with a minimal reproduction.                        |
| `ErrorCode::LicenseFormatInvalid`      | 50    | The credential cannot be parsed. Check the exact key or token and its encoding without logging it.                                       |
| `ErrorCode::LicenseVersionUnsupported` | 51    | The SDK does not support the credential version. Check SDK and account compatibility.                                                    |
| `ErrorCode::LicenseExpired`            | 52    | The credential has expired. Obtain a valid credential through the approved account flow.                                                 |
| `ErrorCode::TokenUpdateUnsupported`    | 53    | Token replacement requires both the original and replacement credentials to be JWTs. Start a new session when changing credential types. |
| `ErrorCode::ModelInvalid`              | 100   | The model data is invalid or corrupted. Obtain a complete compatible model file.                                                         |
| `ErrorCode::ModelVersionUnsupported`   | 101   | The model file format is incompatible with this SDK. Obtain a model in the matching format.                                              |
| `ErrorCode::FilePathInvalid`           | 102   | The model path is not valid UTF-8. Supply a UTF-8 path string.                                                                           |
| `ErrorCode::FileSystemError`           | 103   | The model file cannot be opened or mapped. Check its path, permissions and integrity.                                                    |
| `ErrorCode::ModelDataUnaligned`        | 104   | The model buffer is not aligned to 64 bytes. Use correctly aligned storage and retain it for every dependent object.                     |
| `ErrorCode::ModelTypeUnsupported`      | 105   | The model type does not match the operation. Use the corresponding enhancement, VAD or analysis API.                                     |

## Related

[C++ API index](/reference/sdk/api/cpp/index) · [Troubleshooting](/production/troubleshooting) · [Authentication](/models/get-started/authenticate-apps)
