12 #ifndef DOCWIRE_MAKE_ERROR_H
13 #define DOCWIRE_MAKE_ERROR_H
15 #include "diagnostic_context.h"
18 #include <type_traits>
29 template<
typename... Context>
32 return std::apply([&](
auto&&... args) {
33 return errors::impl<std::remove_cvref_t<decltype(args)>...>(std::move(context_tuple), location);
43 template<
typename... Context>
51 #define DOCWIRE_MAKE_ERROR_AT_LOCATION(explicit_location, ...) \
52 ::docwire::errors::make_error_from_tuple(explicit_location, std::make_tuple(DOCWIRE_DIAGNOSTIC_CONTEXT_MAKE_TUPLE(__VA_ARGS__)))
54 #define DOCWIRE_MAKE_ERROR(...) \
55 DOCWIRE_MAKE_ERROR_AT_LOCATION(docwire::source_location::current() __VA_OPT__(,) __VA_ARGS__)
57 #define DOCWIRE_MAKE_ERROR_PTR(...) \
58 std::make_exception_ptr(DOCWIRE_MAKE_ERROR(__VA_ARGS__))
60 #ifdef DOCWIRE_ENABLE_SHORT_MACRO_NAMES
61 #define make_error DOCWIRE_MAKE_ERROR
62 #define make_error_ptr DOCWIRE_MAKE_ERROR_PTR
Provides features for reporting and handling errors with context data using nested exceptions.
auto make_error_from_tuple(const source_location &location, std::tuple< Context... > &&context_tuple)
Creates an error object from a tuple of context information.
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.
A fallback implementation of source_location for compilers that do not support std::source_location.
Implementation of the error class for a variadic number of context items.