We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5bec5ad commit b9a837dCopy full SHA for b9a837d
src/main.cpp
@@ -60,7 +60,18 @@ void read() {
60
std::cout << ansi::CYAN << "Enter a number of seconds: " << ansi::RESET;
61
std::string seconds;
62
std::getline(std::cin, seconds);
63
- int seconds_int = std::stoi(seconds);
+ int seconds_int;
64
+ try {
65
+ seconds_int = std::stoi(seconds);
66
+ }
67
+ catch (const std::invalid_argument& e) {
68
+ std::cout << ansi::RED << e.what() << ansi::RESET << "\n";
69
+ initialize();
70
71
+ catch (const std::out_of_range& e) {
72
73
74
75
int timer = seconds_int;
76
while (timer > 0) {
77
std::cout << ansi::WHITE << timer << ansi::RESET << "\n";
0 commit comments