13#ifndef RTCTK_COMPONENTFRAMEWORK_EXCEPTIONS_HPP
14#define RTCTK_COMPONENTFRAMEWORK_EXCEPTIONS_HPP
20#include <ciiBasicDataType.hpp>
21#include <ciiException.hpp>
28template <
typename T,
typename N,
typename... Args>
29T CreateExceptionObject(
30 const N& nested_exception,
const char* file,
int line,
const char* function, Args&&... args) {
31 if constexpr (std::is_base_of_v<elt::error::CiiException, T>) {
32 T throwing_exception = T(std::forward<Args>(args)...);
33 throwing_exception.SetFileName(boost::filesystem::path(file).filename().
string());
34 throwing_exception.SetFunctionName(function);
35 throwing_exception.SetLineNumber(line);
36 throwing_exception.SetClassName(boost::core::demangle(
typeid(T).
name()));
37 std::vector<std::string> this_stack;
38 this_stack.push_back(throwing_exception.getCiiMessage());
39 if constexpr (std::is_base_of_v<elt::error::CiiException, N>) {
40 std::vector<std::string> nested_stack = nested_exception.getCiiExceptionStack();
41 this_stack.insert(this_stack.end(), nested_stack.begin(), nested_stack.end());
42 }
else if constexpr (std::is_base_of_v<std::exception, N>) {
43 this_stack.push_back(nested_exception.what());
45 this_stack.push_back(
"Unknown exception.");
47 throwing_exception.SetCiiExceptionStack(this_stack);
48 return throwing_exception;
50 return T(std::forward<Args>(args)...);
60#ifdef CII_THROW_WITH_NESTED
61#undef CII_THROW_WITH_NESTED
63#define CII_THROW_WITH_NESTED(exceptionType_t, nested_exception, ...) \
65 exceptionType_t throwing_exception = CreateExceptionObject<exceptionType_t>( \
66 nested_exception, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \
67 std::throw_with_nested(throwing_exception); \
86 : T(std::forward<E>(e)) {
96 std::string_view lines,
97 std::string_view initial_indent,
98 std::string_view subsequent_indent);
122 std::is_nothrow_constructible_v<detail::UnspecifiedNested<typename std::decay_t<E>>, E&&>) {
123 using Type =
typename std::decay_t<E>;
124 static_assert(std::is_class_v<Type>,
"exception must be a non-union class-type");
191 : m_ptr(), m_exception(&exception){};
196 : m_ptr(std::move(ptr)), m_exception(
nullptr){};
204 std::stringstream ss;
219 }
else if (printer.m_exception) {
228 std::exception_ptr m_ptr;
229 std::exception
const* m_exception;
292 explicit BufferTooSmall(
const std::size_t actual,
const std::size_t expected);
Thrown from service factory methods to indicate the adapter construction failed.
Definition: exceptions.hpp:405
The BufferTooSmall is thrown when an API call fails because the provided buffer is not big enough to ...
Definition: exceptions.hpp:290
std::size_t m_actual
Definition: exceptions.hpp:301
std::size_t GetActualBufferSize() const
Definition: exceptions.hpp:293
std::size_t m_expected
Definition: exceptions.hpp:302
std::size_t GetExpectedBufferSize() const
Definition: exceptions.hpp:296
This Exception is raised when the DDT Publisher returns an error that cannot be handled by the DDT Si...
Definition: exceptions.hpp:377
DdtError(const std::string &message)
Definition: exceptions.hpp:380
This Exception is raised when an invalid ddt sink is requested.
Definition: exceptions.hpp:362
DdtSinkNotFound(const std::string &message)
Definition: exceptions.hpp:365
Thrown in cases where an initialisation routine has failed.
Definition: exceptions.hpp:323
Thrown if an argument passed to a method was invalid.
Definition: exceptions.hpp:310
This Exception is raised when a invalid setting was used in the runtime repo.
Definition: exceptions.hpp:348
InvalidSetting(const std::string &message)
Definition: exceptions.hpp:351
This Exception is raised when the state change requested is invalid.
Definition: exceptions.hpp:334
InvalidStateChange(const std::string &message)
Definition: exceptions.hpp:337
This Exception is raised when the ipc queue returns an error that cannot be handled by the Telemetry ...
Definition: exceptions.hpp:392
IpcqError(const std::string &message)
Definition: exceptions.hpp:395
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition: exceptions.hpp:185
friend std::ostream & operator<<(std::ostream &os, NestedExceptionPrinter const &printer)
Formats exception from printer using PrintNestedExceptions.
Definition: exceptions.hpp:216
std::string Str() const
Convenience function for constructing a std::string from the exception.
Definition: exceptions.hpp:203
NestedExceptionPrinter(std::exception_ptr ptr) noexcept
Construct from exception_ptr.
Definition: exceptions.hpp:195
NestedExceptionPrinter(std::exception const &exception) noexcept
Construct from exception derived from std::exception.
Definition: exceptions.hpp:190
The NotImplementedException is thrown whenever an attempt is made to use a feature or function that h...
Definition: exceptions.hpp:254
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:237
RtctkException() noexcept
Definition: exceptions.cpp:113
virtual ~RtctkException() override=default
The UnsupportedTypeException is thrown whenever an attempt is made to use an unsupported type in the ...
Definition: exceptions.hpp:265
The UnsupportedUriException is thrown whenever an attempt is made to use an unsupported URI in the RT...
Definition: exceptions.hpp:278
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:121
void PrintNestedExceptions(std::ostream &os, std::exception const &exception)
Print nested exception(s) in exception messages to os.
Definition: exceptions.cpp:201
void PrintComposedExceptions(std::ostream &os, std::vector< std::exception_ptr > const &exceptions)
Print composed exception(s) in exception messages to os.
Definition: exceptions.cpp:186
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:26
Definition: commandReplier.cpp:22
name
Definition: wscript:36
Unspecified exception used by WrapWithNested.
Definition: exceptions.hpp:83
UnspecifiedNested(E &&e) noexcept(std::is_nothrow_constructible_v< T, E && >)
Definition: exceptions.hpp:85