Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
refactor: simplify exception handling and code flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Apr 19, 2024
1 parent d6d452c commit 71e13ea
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,19 @@

#include "gomoku.hpp"

int main()
{
try
{
Gomoku gomoku;
gomoku.run();
}
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;
}


return 0;
int main() {
try {
Gomoku gomoku;
gomoku.run();
return 0;
} catch (const std::runtime_error& e) {
std::cerr << "Exception: " << e.what() << "\n";
} catch (...) {
std::cerr << "Unknown exception\n";
}
std::cerr << "Press enter to exit...\n";
std::string line;
std::getline(std::cin, line);
std::getline(std::cin, line);
return 1;
}

0 comments on commit 71e13ea

Please sign in to comment.