From f8c27367893948f6a218ef0be905b0ea7db811d7 Mon Sep 17 00:00:00 2001 From: ShenMian Date: Fri, 19 Apr 2024 22:20:41 +0800 Subject: [PATCH] refactor: simplify exception handling and code flow --- src/main.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 431aa0d..193d68a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,30 +5,18 @@ int main() { - try - { + try { Gomoku gomoku; gomoku.run(); - } - catch(const std::runtime_error& e) - { + return 0; + } catch(const std::runtime_error& e) { std::cerr << "Exception: " << e.what() << "\n"; - std::cerr << "Press enter to exit...\n"; - std::string line; - std::getline(std::cin, line); - std::getline(std::cin, line); - return 1; - } - catch(...) - { - std::cerr << "Unknown exception\b"; - std::cerr << "Press enter to exit...\n"; - std::string line; - std::getline(std::cin, line); - std::getline(std::cin, line); - return 1; + } catch(...) { + std::cerr << "Unknown exception\n"; } - - - return 0; + std::cerr << "Press enter to exit...\n"; + std::string line; + std::getline(std::cin, line); + std::getline(std::cin, line); + return 1; }