|
| | 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.
|
| | 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.
|
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.
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
-
| T | The 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.