From ab8846555cf1fd1b4db98aac9ebacc987a327a89 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 28 May 2024 19:45:50 -0400 Subject: [PATCH] add exception handlers to yaze binary main entry routine --- src/app/yaze.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/app/yaze.cc b/src/app/yaze.cc index 17999a82..9e852a9b 100644 --- a/src/app/yaze.cc +++ b/src/app/yaze.cc @@ -36,12 +36,22 @@ int main(int argc, char** argv) { #ifdef __APPLE__ InitializeCocoa(); #endif - - while (controller.IsActive()) { - controller.OnInput(); - controller.OnLoad(); - controller.DoRender(); + try { + while (controller.IsActive()) { + controller.OnInput(); + controller.OnLoad(); + controller.DoRender(); + } + controller.OnExit(); + } catch (const std::bad_alloc& e) { + std::cerr << "Memory allocation failed: " << e.what() << std::endl; + return EXIT_FAILURE; + } catch (const std::exception& e) { + std::cerr << "Exception: " << e.what() << std::endl; + return EXIT_FAILURE; + } catch (...) { + std::cerr << "Unknown exception" << std::endl; + return EXIT_FAILURE; } - controller.OnExit(); return EXIT_SUCCESS; } \ No newline at end of file