diff --git a/lib/libimhex/include/hex/api/event_manager.hpp b/lib/libimhex/include/hex/api/event_manager.hpp index 6b7882f47..bbe4097e6 100644 --- a/lib/libimhex/include/hex/api/event_manager.hpp +++ b/lib/libimhex/include/hex/api/event_manager.hpp @@ -73,11 +73,12 @@ namespace hex { explicit Event(Callback func) noexcept : m_func(std::move(func)) { } - void operator()(std::string_view eventName, Params... params) const { + template + void call(Params... params) const { try { m_func(params...); } catch (const std::exception &e) { - log::error("An exception occurred while handling event {}: {}", eventName, e.what()); + log::error("An exception occurred while handling event {}: {}", wolv::type::getTypeName(), e.what()); throw; } } @@ -180,12 +181,12 @@ namespace hex { for (const auto &[id, event] : getEvents()) { if (id == E::Id) { - (*static_cast(event.get()))(wolv::type::getTypeName(), std::forward(args)...); + (*static_cast(event.get())).template call(std::forward(args)...); } } #if defined (DEBUG) - if (E::ShouldLog) + if constexpr (E::ShouldLog) log::debug("Event posted: '{}'", wolv::type::getTypeName()); #endif }