int main() { bool more = true; while (more) { try { code } catch (logic_error& e) { cout << "A logic error has occurred: " << e.what() << "\n" << "Retry? (y/n)"; string input; getline(cin, input); if (input == "n") more = false; } } }