C++ · Errors

Errors

#include <ustore/types.hpp> 1.0.0-rc.1 · 084197c4

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

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

Fallible calls return a status_t, a status_code_t beside an optional static note, or an expected, a plain pair of a value and the status_t beside it, and both are [[nodiscard]]. Recovery branches on the code, while the note names the broken invariant, step or resource for logs, falling back to the status name. auto [value, status] decomposes an expected, whose value is default-constructed on failure. Nothing throws, and a callable that may throw, such as a progress handler, does not compile.

auto [db, status] = us::database_t::init_ram();
if (status.failed()) fmt::println(stderr, "{}", status.note);
auto [missing, missing_status] = db.find("nowhere");
if (missing_status == us::status_code_t::not_found_k) fmt::println(stderr, "{}", missing_status.note);

API

Types

status_code_tWhat went wrong, with one enumerator per status the library reports.
types.hpp:73 ↗
enum status_code_t

Values

success_kustore_status_success_k
deferred_kustore_status_deferred_k
out_of_memory_kustore_status_out_of_memory_k
read_only_kustore_status_read_only_k
io_kustore_status_io_k
device_kustore_status_device_k
malformed_kustore_status_malformed_k
internal_kustore_status_internal_k
overflow_kustore_status_overflow_k
uninitialized_kustore_status_uninitialized_k
config_mismatch_kustore_status_config_mismatch_k
contended_kustore_status_contended_k
cancelled_kustore_status_cancelled_k
unsupported_kustore_status_unsupported_k
invalid_argument_kustore_status_invalid_argument_k
not_found_kustore_status_not_found_k
already_exists_kustore_status_already_exists_k
write_conflict_kustore_status_write_conflict_k
read_conflict_kustore_status_read_conflict_k
phantom_conflict_kustore_status_phantom_conflict_k
capacity_exhausted_kustore_status_capacity_exhausted_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:101 ↗
struct status_t

Fields

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

Fields

valuevalue_type_
statusstatus_t