C++ · Errors

Errors

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

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/uform/cpp/errors.md' | claude -p "How would this fit my code?"

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.

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_tWhat went wrong, with one enumerator per status the library reports.
types.hpp:38 ↗
enum status_code_t

Values

success_kuform_status_success_k
deferred_kuform_status_deferred_k
out_of_memory_kuform_status_out_of_memory_k
shape_mismatch_kuform_status_shape_mismatch_k
unsupported_layout_kuform_status_unsupported_layout_k
unknown_kind_kuform_status_unknown_kind_k
io_kuform_status_io_k
device_kuform_status_device_k
malformed_kuform_status_malformed_k
internal_kuform_status_internal_k
overflow_kuform_status_overflow_k
uninitialized_kuform_status_uninitialized_k
config_mismatch_kuform_status_config_mismatch_k
contended_kuform_status_contended_k
cancelled_kuform_status_cancelled_k
unsupported_kuform_status_unsupported_k
invalid_argument_kuform_status_invalid_argument_k
status_tWhy 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 ↗
struct status_t

Fields

codestatus_code_t
notechar const *
expectedA call's value beside its status, bound natively as auto [value, status].
types.hpp:80 ↗
template <typename value_type_>
struct expected

Fields

valuevalue_type_
statusstatus_t