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 Namespace Reference

Provides features for reporting and handling errors with context data using nested exceptions. More...

Classes

struct  base
 Base class for all exceptions in the SDK. More...
 
struct  impl
 Implementation of the error class for a variadic number of context items. More...
 
struct  program_logic
 Program logic failure error tag. More...
 
struct  program_corrupted
 Program corrupted error tag. More...
 
struct  uninterpretable_data
 Uninterpretable data error tag. More...
 
struct  network_failure
 Network failure error tag. More...
 
struct  file_encrypted
 File is encrypted error tag. More...
 
class  nested
 A template class that simplifies the creation of nested exceptions. More...
 

Functions

template<typename T >
bool contains_type (const std::exception &e)
 Checks if the given nested exceptions chain contains a specific type of context.
 
DOCWIRE_CORE_EXPORT void panic (std::exception_ptr eptr)
 Terminates the program with a panic message in debug builds.
 
DOCWIRE_CORE_EXPORT std::string diagnostic_message (const std::exception &e)
 Generates a diagnostic message for the given nested exceptions chain.
 
DOCWIRE_CORE_EXPORT std::string diagnostic_message (std::exception_ptr eptr)
 Generates a diagnostic message for the given nested exceptions chain.
 
template<typename... Context>
auto make_error_from_tuple (const source_location &location, std::tuple< Context... > &&context_tuple)
 Creates an error object from a tuple of context information. More...
 
template<typename... Context>
auto make_error_ptr_from_tuple (const source_location &location, std::tuple< Context... > &&context_tuple)
 Creates an exception_ptr containing an error object from a tuple of context information. More...
 
template<typename Inner , typename Outer >
auto make_nested (Inner &&inner, Outer &&outer)
 Creates a nested exception from an inner exception and an outer exception. More...
 
template<typename Inner , typename Outer , typename... Rest>
auto make_nested (Inner &&inner, Outer &&outer, Rest &&... rest)
 Creates a nested exception from inner exception and multiple outer exceptions. More...
 
template<typename Inner , typename Outer , typename... Rest>
std::exception_ptr make_nested_ptr (Inner &&inner, Outer &&outer, Rest &&... rest)
 Creates a pointer to a nested exception from an inner exception and an outer exception. More...
 

Detailed Description

Provides features for reporting and handling errors with context data using nested exceptions.

See also
handling errors and warnings example

Function Documentation

◆ make_error_from_tuple()

template<typename... Context>
auto docwire::errors::make_error_from_tuple ( const source_location location,
std::tuple< Context... > &&  context_tuple 
)

Creates an error object from a tuple of context information.

Parameters
locationThe source location where the error occurred.
context_tupleA tuple containing context data.
Returns
The constructed error object.

Definition at line 30 of file make_error.h.

◆ make_error_ptr_from_tuple()

template<typename... Context>
auto docwire::errors::make_error_ptr_from_tuple ( const source_location location,
std::tuple< Context... > &&  context_tuple 
)

Creates an exception_ptr containing an error object from a tuple of context information.

Parameters
locationThe source location where the error occurred.
context_tupleA tuple containing context data.
Returns
An exception_ptr to the constructed error.

Definition at line 44 of file make_error.h.

◆ make_nested() [1/2]

template<typename Inner , typename Outer >
auto docwire::errors::make_nested ( Inner &&  inner,
Outer &&  outer 
)

Creates a nested exception from an inner exception and an outer exception.

This function creates a nested exception by throwing the inner exception and catching it, then using the outer exception to create a nested exception.

Template Parameters
InnerThe type of the inner exception.
OuterThe type of the outer exception.
Parameters
innerThe inner exception to be nested. Can be exception object or std::exception_ptr.
outerThe outer exception to wrap the inner exception.
Returns
A nested exception object containing the inner and outer exceptions.
See also
nested
std::nested_exception
std::exception_ptr

Definition at line 84 of file nested_exception.h.

◆ make_nested() [2/2]

template<typename Inner , typename Outer , typename... Rest>
auto docwire::errors::make_nested ( Inner &&  inner,
Outer &&  outer,
Rest &&...  rest 
)

Creates a nested exception from inner exception and multiple outer exceptions.

This function creates a nested exception by recursively calling make_nested with the inner exception and the outer exceptions.

Template Parameters
InnerThe type of the inner exception.
OuterThe type of the outer exception.
RestThe types of additional outer exceptions (additional layers of nesting).
Parameters
innerThe inner exception to be nested. Can be exception object or std::exception_ptr.
outerThe outer exception to wrap the inner exception.
restAdditional outer exceptions to add additional layers of nesting.
Returns
A nested exception object containing whole layers of nested exceptions.
See also
nested
std::nested_exception
std::exception_ptr

Definition at line 119 of file nested_exception.h.

◆ make_nested_ptr()

template<typename Inner , typename Outer , typename... Rest>
std::exception_ptr docwire::errors::make_nested_ptr ( Inner &&  inner,
Outer &&  outer,
Rest &&...  rest 
)

Creates a pointer to a nested exception from an inner exception and an outer exception.

This function creates a pointer to a nested exception by recursively calling make_nested with the inner exception and the outer exceptions and then converting the result to a std::exception_ptr.

Template Parameters
InnerThe type of the inner exception.
OuterThe type of the outer exception.
RestThe types of additional outer exceptions (additional layers of nesting).
Parameters
innerThe inner exception to be nested. Can be exception object or std::exception_ptr.
outerThe outer exception to wrap the inner exception.
restAdditional outer exceptions to add additional layers of nesting.
Returns
A pointer to a nested exception object containing whole layers of nested exceptions.
See also
nested
std::nested_exception
std::exception_ptr

Definition at line 145 of file nested_exception.h.