Lightweight C++17 library for structured errors: kumo::Status and
kumo::Result<T> (StatusOr-style), plus early-return macros.
Inspired by Abseil/turbo Status, trimmed for embedding:
sizeof(Status) == sizeof(uintptr_t)— inline OK / code+SubError+Dap- Heap only when there is a message, payload, or stack
- First-class
SubError(user / errno / errc) andDap(short duration) - String payloads and call-site stacks — no Cord, no fmt dependency
Also includes status/expected.h (tl::expected-style expected<T,E>) as a
separate header-only target. Prefer Status / Result for this library’s
own error model; use expected only when you explicitly want generic T|E.
#include <status/status.h>
kumo::Status Open(std::string_view path) {
if (path.empty()) {
return kumo::make_invalid_argument("empty path")
.with_payload("field", "path")
.with_stack(KUMO_STATUS_TRACE_PARAM);
}
return kumo::OkStatus();
}
kumo::Result<int> Parse(std::string_view s) {
KUMO_RETURN_NOT_OK(Open(s));
if (s == "bad") {
return kumo::make_not_found("missing");
}
return 42; // success: return the value
}
kumo::Status Use() {
int n = 0;
KUMO_MOVE_OR_RAISE(n, Parse("ok"));
(void)n;
return kumo::OkStatus();
}| Header | Contents |
|---|---|
<status/status.h> |
Umbrella: Status + Result + macros |
<status/detail/status.h> |
Status, factories, is_*, SubError, Dap |
<status/detail/result.h> |
Result<T>, BadResultAccess, to_result |
<status/detail/status_macros.h> |
KUMO_RETURN_*, MOVE/COPY_OR_RAISE |
<status/detail/inline_status.h> |
InlineStatus encoding (8-byte word) |
<status/expected.h> |
Generic expected<T,E> (separate from Status) |
See status/skills.h, AGENTS.md, and
docs/AI.md for AI/human API notes (exclusive SubError/Dap masks,
no legacy internal/ tree).
with_*: mutate in place, returnStatus&. No-op on OK for message / payload / stack.- Formatting: pass one preformatted
string/string_view. Defaultto_string()is brief (OKorCODE/CODE: message). Custom:to_string<MyFormat>(). - Result: success =
return value;; errors = build aStatusthen return it asResult<T>. Do not useOkStatus()as a Result error (Debug asserts; Release →internal_error). - Exclusive tags: switching SubError kind or Dap unit clears sibling bits via
kSubErrorExclusiveMask/kDapExclusiveMask. - Macros: optional stack frames when
KUMO_EXTRA_ERROR_CONTEXTis1(default). Set to0before including macros to disable.
CI mirrors xhash: reusable workflows from
kumose/x-ci (Ubuntu / Alpine / CentOS / macOS / Windows)
on master pushes and PRs — see .github/workflows/ci.yml.
Built with kmcmake. kmpkg is optional.
There is no required kmpkg.json (zero third-party package deps). If a build
directory was previously configured with manifest mode, delete it and
reconfigure after removing a manifest.
- Linux / macOS / Windows (MSVC + Ninja recommended)
- CMake ≥ 3.20
- GCC ≥ 9.4 / Clang ≥ 12 / MSVC (VS 2022+)
- Optional:
kmpkgtoolchain viaKMPKG_CMAKE - Optional:
ninjafor--preset=ninja
# Unix Makefiles → build/
cmake --preset=default
cmake --build build -j$(nproc)
# Ninja → build-ninja/
cmake --preset=ninja
cmake --build build-ninja -j$(nproc)Without presets:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)ctest --test-dir build
# or
ctest --test-dir build-ninjaMain targets: status_status_basic_test, status_result_test,
status_macros_no_context_test.
find_package(status REQUIRED)
target_link_libraries(myapp PRIVATE status::status_static)Header-only expected:
target_link_libraries(myapp PRIVATE status::api) # expected.hApache License 2.0 — see LICENSE.