Crunch
A Message Definition Language for Getting Things Right
Loading...
Searching...
No Matches
Crunch::Error Struct Reference

Represents an error occurred during Crunch operations. More...

#include <crunch_types.hpp>

Public Member Functions

constexpr bool operator== (const Error &other) const noexcept=default
 
constexpr bool operator== (ErrorCode c) const noexcept
 Checks if the error matches a specific error code.
 

Static Public Member Functions

static constexpr Error integrity () noexcept
 Creates an error representing an integrity check failure.
 
template<size_t N>
static constexpr Error validation (FieldId id, const char(&msg)[N]) noexcept
 Creates an error representing a validation failure.
 
static constexpr Error deserialization (std::string_view msg="deserialization error") noexcept
 Creates an error representing a deserialization failure.
 
static constexpr Error invalid_message_id () noexcept
 Creates an error representing an invalid message ID.
 
static constexpr Error invalid_format () noexcept
 Creates an error representing an invalid serialization format.
 
template<size_t N>
static constexpr Error capacity_exceeded (FieldId id, const char(&msg)[N]) noexcept
 Creates an error representing capacity exceeded. Used for strings and aggregated fields.
 

Public Attributes

ErrorCode code
 The error code.
 
FieldId field_id {0}
 
std::string_view message {}
 Static error message string.
 

Detailed Description

Represents an error occurred during Crunch operations.

Contains an error code, an optional field ID related to the error, and a descriptive message.

Member Function Documentation

◆ capacity_exceeded()

template<size_t N>
static constexpr Error Crunch::Error::capacity_exceeded ( FieldId  id,
const char(&)  msg[N] 
)
inlinestaticconstexprnoexcept

Creates an error representing capacity exceeded. Used for strings and aggregated fields.

Template Parameters
NSize of the message string literal.
Parameters
idThe FieldId.
msgDescription.

◆ deserialization()

static constexpr Error Crunch::Error::deserialization ( std::string_view  msg = "deserialization error")
inlinestaticconstexprnoexcept

Creates an error representing a deserialization failure.

Parameters
msgDescription of the deserialization error.

◆ validation()

template<size_t N>
static constexpr Error Crunch::Error::validation ( FieldId  id,
const char(&)  msg[N] 
)
inlinestaticconstexprnoexcept

Creates an error representing a validation failure.

Template Parameters
NSize of the message string literal.
Parameters
idThe FieldId that failed validation.
msgThe failure description.

Member Data Documentation

◆ field_id

FieldId Crunch::Error::field_id {0}

ID of the field associated with the error (0 if not applicable).


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