parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
parcel::ParcelError Struct Reference

Structured error returned by the non-throwing try_* parsing surface. More...

#include <error.h>

Public Types

enum class  Code {
  InvalidJson , KindMismatch , UnknownKind , MissingField ,
  TypeError
}
 Coarse error categories. More...
 

Public Member Functions

std::string to_string () const
 Render the error as code: message [kind=…] [field=…].
 

Static Public Member Functions

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.
 

Public Attributes

Code code {Code::InvalidJson}
 Coarse error code.
 
std::string message
 Human-readable message — never empty.
 
std::string kind
 Kind id involved in the error (may be empty).
 
std::string field
 Struct field name involved in the error (may be empty).
 

Detailed Description

Structured error returned by the non-throwing try_* parsing surface.

Carries a coarse code, a human-readable message, and (when relevant) the cell kind id and field name involved.

Member Enumeration Documentation

◆ Code

enum class parcel::ParcelError::Code
strong

Coarse error categories.

Enumerator
InvalidJson 

Input was not parseable JSON or had wrong shape.

KindMismatch 

JSON "k" did not match the expected kind.

UnknownKind 

JSON "k" referenced a kind not registered.

MissingField 

A required struct field was missing.

TypeError 

A typed value (e.g.

struct field) failed conversion.

Member Function Documentation

◆ to_string()

std::string parcel::ParcelError::to_string ( ) const
inline

Render the error as code: message [kind=…] [field=…].

Returns
Compact diagnostic string.

The documentation for this struct was generated from the following file: