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 f8c2736
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit f8c2736

Please sign in to comment.