DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
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. More...
 
std::type_info const & context_type (size_t index) const noexcept override
 Get the type information of the context. More...
 
std::string context_string (size_t index) const override
 Get the string representation of the context. More...
 
size_t context_count () const noexcept override
 Get the number of context items. More...
 
- 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. More...
 
virtual const char * what () const noexcept override
 Get the exception type. More...
 

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

Definition at line 148 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 189 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 224 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 215 of file error.h.

◆ context_type()

template<typename... T>
std::type_info const& docwire::errors::impl< T >::context_type ( 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 202 of file error.h.


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