23#if __has_include(<expected>)
27#if defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L
28#define PARCEL_HAS_EXPECTED 1
30#define PARCEL_HAS_EXPECTED 0
107 make(
const Code c, std::string msg, std::string kind_id = {}, std::string fld = {}) {
108 return ParcelError{c, std::move(msg), std::move(kind_id), std::move(fld)};
129 const std::string& msg,
130 std::string kind_id = {},
131 std::string field_name = {})
132 : std::runtime_error(msg), code_(c), kind_(std::move(kind_id)),
133 field_(std::move(field_name)) {}
139 [[nodiscard]] std::string_view kind_id()
const noexcept {
142 [[nodiscard]] std::string_view field_name()
const noexcept {
161 std::string kind_id = {},
162 std::string field_name = {})
193 std::string kind_id = {},
194 std::string field_name = {})
JSON shape was wrong (missing/non-string k, missing v, etc.).
Definition error.h:158
k field was present but did not match the expected kind.
Definition error.h:168
Required struct field absent from the JSON payload.
Definition error.h:182
Base class for parcel deserialization exceptions.
Definition error.h:121
ParcelError to_error() const
Project to a ParcelError value (used by try_* adapters).
Definition error.h:147
Typed value (cast, struct field, etc.) failed conversion.
Definition error.h:190
Registry was asked to dispatch a kind it does not know.
Definition error.h:175
Structured error returned by the non-throwing try_* parsing surface.
Definition error.h:41
std::string kind
Kind id involved in the error (may be empty).
Definition error.h:61
std::string message
Human-readable message — never empty.
Definition error.h:59
std::string field
Struct field name involved in the error (may be empty).
Definition error.h:63
std::string to_string() const
Render the error as code: message [kind=…] [field=…].
Definition error.h:69
static ParcelError make(const Code c, std::string msg, std::string kind_id={}, std::string fld={})
Construct from code, message, and optional kind/field tags.
Definition error.h:107
Code code
Coarse error code.
Definition error.h:57
Code
Coarse error categories.
Definition error.h:43
@ TypeError
A typed value (e.g.
@ KindMismatch
JSON "k" did not match the expected kind.
@ InvalidJson
Input was not parseable JSON or had wrong shape.
@ MissingField
A required struct field was missing.
@ UnknownKind
JSON "k" referenced a kind not registered.