DocWire SDK
DocWire SDK: Deterministic, auditable, and secure data processing in C++20. On-premise by default. No compromises on computational speed.
Loading...
Searching...
No Matches
docwire::errors::impl< T > Struct Template Reference

Implementation of the error class for a variadic number of context items. More...

#include <error.h>

Inheritance diagram for docwire::errors::impl< T >:
docwire::errors::base

Public Member Functions

 impl (const std::tuple< T... > &context_tuple, const source_location &location=source_location::current())
 Constructs an error object from a tuple of context items.
type_id context_type_id (size_t index) const noexcept override
 Get the type information of the context.
std::string context_string (size_t index) const override
 Get the string representation of the context.
size_t context_count () const noexcept override
 Get the number of context items.
Public Member Functions inherited from docwire::errors::base
 base (const source_location &location=source_location::current())
 Constructs a base object with the current source location.
 base (const base &)
 base (base &&)
base & operator= (const base &)
base & operator= (base &&)
const char * what () const noexcept override
 Get the exception type.

Public Attributes

std::tuple< T... > context
 A tuple holding all context items provided when the error was created.
Public Attributes inherited from docwire::errors::base
source_location location
 The source location where the exception was thrown.

Detailed Description

template<typename... T>
struct docwire::errors::impl< T >

Implementation of the error class for a variadic number of context items.

This class is used to throw exceptions with additional context information. It can store multiple context items of different types.

// It is recommended to use the make_error macro instead of constructing impl directly.
throw make_error("A simple error message");
std::string file_path = "/path/to/file";
throw make_error("File not found", errors::file_not_found{}, file_path);

While the errors::impl template can be used directly, it is strongly recommended to use the make_error macro, which correctly handles context creation and source location capture.

The class stores the context items in a tuple and provides methods to access them by index.

Template Parameters
TThe types of the context items.
See also
errors::base
errors::make_error
errors::diagnostic_message
handling errors and warnings example
Examples
handling_errors_and_warnings.cpp.

Definition at line 167 of file error.h.

Constructor & Destructor Documentation

◆ impl()

template<typename... T>
docwire::errors::impl< T >::impl ( const std::tuple< T... > & context_tuple,
const source_location & location = source_location::current() )
inlineexplicit

Constructs an error object from a tuple of context items.

Parameters
context_tupleA tuple containing the context to be stored.
locationThe source location of the exception (initialized by current location by default).

Definition at line 208 of file error.h.

Member Function Documentation

◆ context_count()

template<typename... T>
size_t docwire::errors::impl< T >::context_count ( ) const
inlineoverridevirtualnoexcept

Get the number of context items.

Returns
The number of context items stored in this error object.

Implements docwire::errors::base.

Definition at line 243 of file error.h.

◆ context_string()

template<typename... T>
std::string docwire::errors::impl< T >::context_string ( size_t index) const
inlineoverridevirtual

Get the string representation of the context.

Parameters
indexThe index of the context item.
Returns
The string representation of the context item at the given index.
See also
context_type
context

Implements docwire::errors::base.

Definition at line 234 of file error.h.

◆ context_type_id()

template<typename... T>
type_id docwire::errors::impl< T >::context_type_id ( size_t index) const
inlineoverridevirtualnoexcept

Get the type information of the context.

Parameters
indexThe index of the context item.
Returns
The type information of the context item at the given index.
See also
context_string
context

Implements docwire::errors::base.

Definition at line 221 of file error.h.

Member Data Documentation

◆ context

template<typename... T>
std::tuple<T...> docwire::errors::impl< T >::context

A tuple holding all context items provided when the error was created.

Definition at line 200 of file error.h.


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