diff --git a/src/core/src/platforms/all/helpers/helpers/logger.hpp b/src/core/src/platforms/all/helpers/helpers/logger.hpp index 421b2a4a..624e6e81 100644 --- a/src/core/src/platforms/all/helpers/helpers/logger.hpp +++ b/src/core/src/platforms/all/helpers/helpers/logger.hpp @@ -128,8 +128,12 @@ BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_logger, my_logger_mt) { */ template inline void log(severity_level lvl, fmt::format_string format_str, Args &&...args) { - auto msg = fmt::format(format_str, std::forward(args)...); - BOOST_LOG_SEV(my_logger::get(), lvl) << msg; + try { + auto msg = fmt::format(format_str, std::forward(args)...); + BOOST_LOG_SEV(my_logger::get(), lvl) << msg; + } catch (const std::exception &e) { + std::cout << "Failed to format log message: " << e.what(); + } } inline logs::severity_level parse_level(const std::string &level) { diff --git a/src/moonlight-protocol/crypto/src/utils.cpp b/src/moonlight-protocol/crypto/src/utils.cpp index b45fd57a..21507475 100644 --- a/src/moonlight-protocol/crypto/src/utils.cpp +++ b/src/moonlight-protocol/crypto/src/utils.cpp @@ -1,10 +1,12 @@ +#include #include +#include #include #include void handle_openssl_error(const std::string &msg) { ERR_print_errors_fp(stderr); - throw std::runtime_error(msg); + std::cout << msg << std::endl; } std::string uc_to_str(unsigned char *uc, int len) { diff --git a/src/moonlight-server/control/control.cpp b/src/moonlight-server/control/control.cpp index 4c93bcd6..4399c760 100644 --- a/src/moonlight-server/control/control.cpp +++ b/src/moonlight-server/control/control.cpp @@ -88,8 +88,8 @@ bool encrypt_and_send(std::string_view payload, std::size_t session_id) { auto clients = connected_clients.load(); auto enet_peer = clients->find(session_id); - if (enet_peer == nullptr) { - logs::log(logs::debug, "[ENET] Unable to find enet client {}", session_id); + if (!enet_peer || payload == nullptr || aes_key == nullptr) { + logs::log(logs::debug, "[ENET] Unable to send encrypted packed {}", session_id); return false; } else { auto encrypted = control::encrypt_packet(aes_key, 0, payload); // TODO: seq?