diff --git a/include/up-cpp/utils/CallbackConnection.h b/include/up-cpp/utils/CallbackConnection.h index 836efc78b..c5416992f 100644 --- a/include/up-cpp/utils/CallbackConnection.h +++ b/include/up-cpp/utils/CallbackConnection.h @@ -266,11 +266,21 @@ struct [[nodiscard]] CalleeHandle { "Attempted to create a connected CalleeHandle with bad " "connection pointer"); } + if (!callback_) { throw BadConnection( "Attempted to create a connected CalleeHandle with bad " "callback pointer"); } + + const auto& callback_obj = *callback_; + if (!callback_obj) { + throw EmptyFunctionObject("Callback function is empty"); + } + + if (cleanup_ && !cleanup_.value()) { + throw EmptyFunctionObject("Cleanup function is empty"); + } } /// @brief CalleeHandles can be move constructed