# Errors

> Every fallible call answers a status_t alone, or an expected<T>, a plain pair unpacked as auto [value, status], whose value is default-constructed on failure.

`#include <uform/types.hpp>` 4.0.0-rc.1 · c58749fe

Every fallible call answers a `status_t` alone, or an `expected<T>`, a plain pair unpacked as `auto [value, status]`, whose value is default-constructed on failure. A `status_t` carries a `status_code_t` and an optional static `note`, so nothing allocates on the failure path. Recovery branches on the code, while the note names the broken invariant, step or resource for logs, falling back to the status name. A failure the SDK catches before the call crosses the boundary reports the status the library would have used.

```cpp
auto [encoded, status] = model.on(executor).text_encode(texts, uf::encode_outputs_t::embeddings_k, uform_scalar_f32_k, arena);
if (status == uf::status_code_t::contended_k) retry();
else if (status.failed()) fmt::println(stderr, "{}", status.note);
else fmt::println("{} items", encoded.embeddings.written);
```

`status_code_t` carries the C enumerators’ values, and `status_code_t::deferred_k` reaches only `deferred::status`. The C name tables, such as `uform_status_name` and `uform_scalar_from_name`, are called directly, since every SDK header includes its C header. A handler is a `noexcept` callable, so no fault unwinds through the library.

## API

### Types

#### `status_code_t`

What went wrong, with one enumerator per status the library reports.

[types.hpp:38 ↗](https://github.com/unum-cloud/UForm/blob/c58749fe4bb208356cc78a87357ab007041c515b/cpp/uform/types.hpp#L38)

```cpp
enum status_code_t
```

#### Values

| `success_k` | `uform_status_success_k` | |
| - | - | - |
| `deferred_k` | `uform_status_deferred_k` | |
| `out_of_memory_k` | `uform_status_out_of_memory_k` | |
| `shape_mismatch_k` | `uform_status_shape_mismatch_k` | |
| `unsupported_layout_k` | `uform_status_unsupported_layout_k` | |
| `unknown_kind_k` | `uform_status_unknown_kind_k` | |
| `io_k` | `uform_status_io_k` | |
| `device_k` | `uform_status_device_k` | |
| `malformed_k` | `uform_status_malformed_k` | |
| `internal_k` | `uform_status_internal_k` | |
| `overflow_k` | `uform_status_overflow_k` | |
| `uninitialized_k` | `uform_status_uninitialized_k` | |
| `config_mismatch_k` | `uform_status_config_mismatch_k` | |
| `contended_k` | `uform_status_contended_k` | |
| `cancelled_k` | `uform_status_cancelled_k` | |
| `unsupported_k` | `uform_status_unsupported_k` | |
| `invalid_argument_k` | `uform_status_invalid_argument_k` | |

#### `status_t`

Why a call failed: a code recovery branches on, and an optional static note naming the broken invariant, step or resource, for logs and regression analysis.

[types.hpp:62 ↗](https://github.com/unum-cloud/UForm/blob/c58749fe4bb208356cc78a87357ab007041c515b/cpp/uform/types.hpp#L62)

```cpp
struct status_t
```

#### Fields

| `code` | `status_code_t` | |
| - | - | - |
| `note` | `char const *` | |

#### `expected`

A call's value beside its status, bound natively as `auto [value, status]`.

[types.hpp:80 ↗](https://github.com/unum-cloud/UForm/blob/c58749fe4bb208356cc78a87357ab007041c515b/cpp/uform/types.hpp#L80)

```cpp
template <typename value_type_>
struct expected
```

#### Fields

| `value` | `value_type_` | |
| - | - | - |
| `status` | `status_t` | |
