7namespace opcua::detail {
13class ExceptionCatcher {
15 void setException(std::exception_ptr exception)
noexcept {
16 exception_ = std::move(exception);
19 bool hasException() const noexcept {
20 return exception_ !=
nullptr;
25 std::rethrow_exception(std::exchange(exception_,
nullptr));
29 template <
typename Callback,
typename... Args>
30 void invoke(Callback&& callback, Args&&... args)
noexcept {
31 static_assert(std::is_void_v<std::invoke_result_t<Callback, Args&&...>>);
33 std::invoke(std::forward<Callback>(callback), std::forward<Args>(args)...);
35 setException(std::current_exception());
52 template <
typename Callback>
53 auto wrapCallback(Callback&& callback)
noexcept {
54 return [
this, cb = std::forward<Callback>(callback)](
auto&&...
args) {
55 this->invoke(std::move(cb), std::forward<
decltype(args)>(args)...);
60 std::exception_ptr exception_;
static UA_LogCategory const char va_list args