DocWire SDK
DocWire SDK: Deterministic, auditable, and secure data processing in C++20. On-premise by default. No compromises on computational speed.
Toggle main menu visibility
Loading...
Searching...
No Matches
make_error.h
1
/*********************************************************************************************************************************************/
2
/* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3
/* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4
/* document analysis. Offline processing possible for security and confidentiality */
5
/* */
6
/* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7
/* Project homepage: https://github.com/docwire/docwire */
8
/* */
9
/* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DocWire-Commercial */
10
/*********************************************************************************************************************************************/
11
12
#ifndef DOCWIRE_MAKE_ERROR_H
13
#define DOCWIRE_MAKE_ERROR_H
14
15
#include "diagnostic_context.h"
16
#include "error.h"
// IWYU pragma: keep
17
#include <tuple>
// IWYU pragma: keep
18
#include <type_traits>
// IWYU pragma: keep
19
20
namespace
docwire::errors
21
{
22
29
template
<
typename
... Context>
30
auto
make_error_from_tuple
(
const
source_location
& location, std::tuple<Context...>&& context_tuple)
31
{
32
return
std::apply([&](
auto
&&... args) {
33
return
errors::impl
<std::remove_cvref_t<
decltype
(args)>...>(std::move(context_tuple), location);
34
}, context_tuple);
35
}
36
43
template
<
typename
... Context>
44
auto
make_error_ptr_from_tuple
(
const
source_location
& location, std::tuple<Context...>&& context_tuple)
45
{
46
return
std::make_exception_ptr(
make_error_from_tuple
(location, std::move(context_tuple)));
47
}
48
49
}
// namespace docwire::errors
50
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__)))
53
54
#define DOCWIRE_MAKE_ERROR(...) \
55
DOCWIRE_MAKE_ERROR_AT_LOCATION(docwire::source_location::current() __VA_OPT__(,) __VA_ARGS__)
56
57
#define DOCWIRE_MAKE_ERROR_PTR(...) \
58
std::make_exception_ptr(DOCWIRE_MAKE_ERROR(__VA_ARGS__))
59
60
#ifdef DOCWIRE_ENABLE_SHORT_MACRO_NAMES
61
#define make_error DOCWIRE_MAKE_ERROR
62
#define make_error_ptr DOCWIRE_MAKE_ERROR_PTR
63
#endif
64
65
#endif
docwire::errors
Provides features for reporting and handling errors with context data using nested exceptions.
Definition
contains_type.h:19
docwire::errors::make_error_from_tuple
auto make_error_from_tuple(const source_location &location, std::tuple< Context... > &&context_tuple)
Creates an error object from a tuple of context information.
Definition
make_error.h:30
docwire::errors::make_error_ptr_from_tuple
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.
Definition
make_error.h:44
docwire::source_location
basic_source_location source_location
A type that describes a location in source code. Uses a custom fallback implementation.
Definition
source_location.h:63
docwire::errors::impl
Implementation of the error class for a variadic number of context items.
Definition
error.h:168
make_error.h
Generated by
1.18.0