Go to the documentation of this file.
12 #ifndef RTCTK_COMPONENTFRAMEWORK_EXCEPTIONS_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_EXCEPTIONS_HPP
15 #include <string_view>
16 #include <type_traits>
19 #include <ciiBasicDataType.hpp>
20 #include <ciiException.hpp>
27 template <
typename T,
typename N,
typename...
Args>
28 T CreateExceptionObject(
29 const N& nested_exception,
const char* file,
int line,
const char*
function,
Args&&... args) {
30 if constexpr (std::is_base_of_v<elt::error::CiiException, T>) {
31 T throwing_exception = T(std::forward<Args>(args)...);
32 throwing_exception.SetFileName(boost::filesystem::path(file).
filename().
string());
33 throwing_exception.SetFunctionName(
function);
34 throwing_exception.SetLineNumber(line);
35 throwing_exception.SetClassName(boost::core::demangle(
typeid(T).
name()));
36 std::vector<std::string> this_stack;
37 this_stack.push_back(throwing_exception.getCiiMessage());
38 if constexpr (std::is_base_of_v<elt::error::CiiException, N>) {
39 std::vector<std::string> nested_stack = nested_exception.getCiiExceptionStack();
40 this_stack.insert(this_stack.end(), nested_stack.begin(), nested_stack.end());
41 }
else if constexpr (std::is_base_of_v<std::exception, N>) {
42 this_stack.push_back(nested_exception.what());
44 this_stack.push_back(
"Unknown exception.");
46 throwing_exception.SetCiiExceptionStack(this_stack);
47 return throwing_exception;
49 return T(std::forward<Args>(args)...);
59 #ifdef CII_THROW_WITH_NESTED
60 #undef CII_THROW_WITH_NESTED
62 #define CII_THROW_WITH_NESTED(exceptionType_t, nested_exception, ...) \
64 exceptionType_t throwing_exception = CreateExceptionObject<exceptionType_t>( \
65 nested_exception, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \
66 std::throw_with_nested(throwing_exception); \
69 #endif // CII_THROW_WITH_NESTED
83 : T(
std::forward<E>(e)) {
93 std::string_view lines,
94 std::string_view initial_indent,
95 std::string_view subsequent_indent);
118 using Type =
typename std::decay_t<E>;
119 static_assert(std::is_class_v<Type>,
"exception must be a non-union class-type");
163 : m_ptr(), m_exception(&exception){};
168 : m_ptr(std::move(ptr)), m_exception(
nullptr){};
176 std::stringstream ss;
191 }
else if (printer.m_exception) {
200 std::exception_ptr m_ptr;
201 std::exception
const* m_exception;
253 explicit BufferTooSmall(
const std::size_t actual,
const std::size_t expected);
273 #endif // RTCTK_COMPONENTFRAMEWORK_EXCEPTIONS_HPP
The UnsupportedTypeException is thrown whenever an attempt is made to use an unsupported type in the ...
Definition: exceptions.hpp:231
Unspecified exception used by WrapWithNested.
Definition: exceptions.hpp:80
name
Definition: wscript:15
NestedExceptionPrinter(std::exception_ptr ptr) noexcept
Construct from exception_ptr.
Definition: exceptions.hpp:167
std::ostream & JoinLines(std::ostream &os, std::string_view lines, std::string_view initial_indent, std::string_view subsequent_indent)
Join each line in lines with.
Definition: exceptions.cpp:24
The NotImplementedException is thrown whenever an attempt is made to use a feature or function that h...
Definition: exceptions.hpp:222
void PrintNestedExceptions(std::ostream &os, std::exception const &exception)
Print nested exception(s) in exception messages to os.
Definition: exceptions.cpp:157
RtctkException() noexcept
Definition: exceptions.cpp:101
std::size_t m_expected
Definition: exceptions.hpp:263
detail::Args Args
Definition: rtcComponentMain.hpp:33
Definition: commandReplier.cpp:20
auto WrapWithNested(E &&exception) noexcept(std::is_nothrow_constructible_v< detail::UnspecifiedNested< typename std::decay_t< E >>, E && >)
Constructs an unspecified exception that derives from both the provided object and std::nested_except...
Definition: exceptions.hpp:116
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:207
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition: exceptions.hpp:157
friend std::ostream & operator<<(std::ostream &os, NestedExceptionPrinter const &printer)
Formats exception from printer using PrintNestedExceptions.
Definition: exceptions.hpp:188
NotImplementedException(const std::string &feature)
Definition: exceptions.cpp:113
UnsupportedTypeException(const std::string &type)
Definition: exceptions.cpp:120
virtual ~RtctkException() override=default
std::size_t GetActualBufferSize() const
Definition: exceptions.hpp:254
UnsupportedUriException(const elt::mal::Uri &uri)
Definition: exceptions.cpp:136
std::string Str() const
Convenience function for constructing a std::string from the exception.
Definition: exceptions.hpp:175
NestedExceptionPrinter(std::exception const &exception) noexcept
Construct from exception derived from std::exception.
Definition: exceptions.hpp:162
The BufferTooSmall is thrown when an API call fails because the provided buffer is not big enough to ...
Definition: exceptions.hpp:251
Definition: mudpiProcessingError.hpp:119
std::size_t m_actual
Definition: exceptions.hpp:262
InvalidArgumentException(const std::string &message)
Definition: exceptions.cpp:151
std::size_t GetExpectedBufferSize() const
Definition: exceptions.hpp:257
BufferTooSmall(const std::size_t actual, const std::size_t expected)
Definition: exceptions.cpp:142
UnspecifiedNested(E &&e) noexcept(std::is_nothrow_constructible_v< T, E && >)
Definition: exceptions.hpp:82
The UnsupportedUriException is thrown whenever an attempt is made to use an unsupported URI in the RT...
Definition: exceptions.hpp:242
Definition: exceptions.hpp:266
filename
Definition: rtctkExampleDataTaskGenFitsData.py:11