From 1e3616919197a7c73e4169a1afd08b950a7e074b Mon Sep 17 00:00:00 2001 From: chatlanin Date: Mon, 3 Feb 2025 17:58:07 +0300 Subject: [PATCH] add try_catch --- src/glfw/glfw.cpp | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/src/glfw/glfw.cpp b/src/glfw/glfw.cpp index 9532c97..b407f6c 100755 --- a/src/glfw/glfw.cpp +++ b/src/glfw/glfw.cpp @@ -182,21 +182,42 @@ namespace VE } } - d->execute(e); + try + { + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); glfwSetScrollCallback(m_win, [](GLFWwindow* w, double xOffset, double yOffset) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_target::VE, event_type::MOUSE_SCROLL, std::pair{ static_cast(xOffset), static_cast(yOffset) } }; - d->execute(e); + try + { + event e{ event_target::VE, event_type::MOUSE_SCROLL, std::pair{ static_cast(xOffset), static_cast(yOffset) } }; + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); glfwSetCursorPosCallback(m_win, [](GLFWwindow* w, double xPos, double yPos) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_target::VE, event_type::MOUSE_CURSOR_POSITION, std::pair{ static_cast(xPos), static_cast(yPos) } }; - d->execute(e); + try + { + event e{ event_target::VE, event_type::MOUSE_CURSOR_POSITION, std::pair{ static_cast(xPos), static_cast(yPos) } }; + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); } @@ -210,25 +231,44 @@ namespace VE d->m_width = width; d->m_height = height; - event e{ event_target::VE, event_type::WINDOW_RESIZE, std::pair{ static_cast(width), static_cast(height) } }; - d->execute(e); + try + { + event e{ event_target::VE, event_type::WINDOW_RESIZE, std::pair{ static_cast(width), static_cast(height) } }; + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); glfwSetWindowCloseCallback(m_win, [](GLFWwindow* w) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_target::VE, event_type::WINDOW_CLOSE, nullptr }; - d->execute(e); + try + { + event e{ event_target::VE, event_type::WINDOW_CLOSE, nullptr }; + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); glfwSetWindowFocusCallback(m_win, [](GLFWwindow* w, int focused) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_target::VE, event_type::WINDOW_FOCUS, focused }; - d->execute(e); + try + { + event e{ event_target::VE, event_type::WINDOW_FOCUS, focused }; + d->execute(e); + } + catch(std::exception& e) + { + hack::log()("VE_ERROR: ", e.what()); + } }); - - } void glfw::set_opengl()