CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
26 #include <boost/exception/exception.hpp>
27 #include <boost/exception/info.hpp>
28 #include <boost/throw_exception.hpp>
32 #if defined(WIN32) || defined(WIN64)
33 #define VISIBLE_EXCEPTION_ATTRIBUTE
35 #define VISIBLE_EXCEPTION_ATTRIBUTE __attribute__ ((visibility ("default")))
41 template<
typename TStlException>
50 : TStlException(rhs.what())
51 ,
boost::exception(rhs)
52 , utils::NonCopyable()
57 : TStlException(rhs.what())
58 ,
boost::exception(std::move(rhs))
59 , utils::NonCopyable()
63 template<
typename TStlException>
98 namespace exception_detail {
101 template<
typename T,
typename X = std::enable_if_t<!std::is_po
inter_v<T>>>
107 template<
typename TValue,
typename TTag>
119 template<
typename TInputIterator>
123 std::ostringstream out;
129 template<
typename TErrorParam>
134 static auto From(
const T& value) {
135 return boost::error_info<TErrorParam, decltype(ConvertToValue(value))>(
ConvertToValue(value));
142 #define CATAPULT_THROW_EXCEPTION(EXCEPTION) \
143 BOOST_THROW_EXCEPTION(EXCEPTION)
146 #define CATAPULT_THROW_AND_LOG_0(TYPE, MESSAGE) { \
147 CATAPULT_LOG(error) << "Throwing exception: " << MESSAGE; \
148 CATAPULT_THROW_EXCEPTION(TYPE(MESSAGE)); \
152 #define CATAPULT_THROW_AND_LOG_1(TYPE, MESSAGE, PARAM1) { \
153 auto detail1 = exception_detail::Make<ErrorParam1>::From(PARAM1); \
154 CATAPULT_LOG(error) << "Throwing exception: " << MESSAGE << " (" << detail1.value() << ")"; \
155 CATAPULT_THROW_EXCEPTION(TYPE(MESSAGE) << detail1); \
159 #define CATAPULT_THROW_AND_LOG_2(TYPE, MESSAGE, PARAM1, PARAM2) { \
160 auto detail1 = exception_detail::Make<ErrorParam1>::From(PARAM1); \
161 auto detail2 = exception_detail::Make<ErrorParam2>::From(PARAM2); \
162 CATAPULT_LOG(error) << "Throwing exception: " << MESSAGE << " (" << detail1.value() << ", " << detail2.value() << ")"; \
163 CATAPULT_THROW_EXCEPTION(TYPE(MESSAGE) << detail1 << detail2); \
167 #define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE) \
168 CATAPULT_THROW_AND_LOG_0(catapult_runtime_error, MESSAGE)
171 #define CATAPULT_THROW_RUNTIME_ERROR_1(MESSAGE, PARAM1) \
172 CATAPULT_THROW_AND_LOG_1(catapult_runtime_error, MESSAGE, PARAM1)
175 #define CATAPULT_THROW_RUNTIME_ERROR_2(MESSAGE, PARAM1, PARAM2) \
176 CATAPULT_THROW_AND_LOG_2(catapult_runtime_error, MESSAGE, PARAM1, PARAM2)
179 #define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE) \
180 CATAPULT_THROW_AND_LOG_0(catapult_invalid_argument, MESSAGE)
183 #define CATAPULT_THROW_INVALID_ARGUMENT_1(MESSAGE, PARAM1) \
184 CATAPULT_THROW_AND_LOG_1(catapult_invalid_argument, MESSAGE, PARAM1)
187 #define CATAPULT_THROW_INVALID_ARGUMENT_2(MESSAGE, PARAM1, PARAM2) \
188 CATAPULT_THROW_AND_LOG_2(catapult_invalid_argument, MESSAGE, PARAM1, PARAM2)
191 #define CATAPULT_THROW_OUT_OF_RANGE(MESSAGE) \
192 CATAPULT_THROW_AND_LOG_0(catapult_out_of_range, MESSAGE)
195 #define CATAPULT_THROW_FILE_IO_ERROR(MESSAGE) \
196 CATAPULT_THROW_AND_LOG_0(catapult_file_io_error, MESSAGE)
catapult_error(const catapult_error &rhs)
Copy constructs an exception from rhs.
Definition: exceptions.h:49
constexpr T ConvertToValue(const T &value)
Definition: exceptions.h:102
catapult_error(catapult_error< TStlException > &&rhs)
Move constructs an exception from rhs.
Definition: exceptions.h:83
Tag for first custom exception parameter.
Definition: exceptions.h:93
Helper class for creating boost::error_info.
Definition: exceptions.h:130
Definition: IoThreadPool.h:25
constexpr ValueType unwrap() const
Unwraps this value and returns the underlying raw value.
Definition: BaseValue.h:53
Immutable wrapper for basic types, to provide some type-safety.
Definition: BaseValue.h:100
static auto From(const T &value)
Creates a boost::error_info with the specified value.
Definition: exceptions.h:134
catapult_error(const char *what)
Creates an exception with a message (what).
Definition: exceptions.h:67
catapult_error(catapult_error &&rhs)
Move constructs an exception from rhs.
Definition: exceptions.h:75
catapult_error(const catapult_error &rhs)
Copy constructs an exception from rhs.
Definition: exceptions.h:71
#define VISIBLE_EXCEPTION_ATTRIBUTE
Definition: exceptions.h:35
Definition: AddressExtractionExtension.cpp:28
catapult_error(const catapult_error< TStlException > &rhs)
Copy constructs an exception from rhs.
Definition: exceptions.h:79
Base class for all catapult exceptions that derives from both std::exception and boost::exception.
Definition: exceptions.h:42
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
catapult_error(catapult_error &&rhs)
Move constructs an exception from rhs.
Definition: exceptions.h:56
catapult_error(const char *what)
Creates an exception with a message (what).
Definition: exceptions.h:45
Tag for second custom exception parameter.
Definition: exceptions.h:96