From dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 20:33:26 +0300 Subject: Autocommit at 30.05.2022 @ 20:33 --- src/Generic/ConsoleInterface/Menu.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Generic/ConsoleInterface/Menu.cpp') diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp index d547990..9c2fca5 100644 --- a/src/Generic/ConsoleInterface/Menu.cpp +++ b/src/Generic/ConsoleInterface/Menu.cpp @@ -36,15 +36,13 @@ void Menu::navigate() const { char buffer[MAX_LINE_WIDTH]; unsigned startIndex, commandEnd, paramsStart, index; - while (1) { + bool hasThrown = false; + while (!hasThrown) { startIndex = 0; inputLineBox(buffer, MAX_LINE_WIDTH, false); while (buffer[startIndex] == ' ') startIndex++; - if (strncmp(buffer + startIndex, "quit", 4) == 0) - break; - commandEnd = startIndex; while (buffer[commandEnd] != ' ' && buffer[commandEnd] != '\n' && buffer[commandEnd] != '\0') commandEnd++; @@ -63,6 +61,12 @@ void Menu::navigate() const { continue; } - menuOptions[index].run(buffer + paramsStart); + try { + menuOptions[index].run(buffer + paramsStart); + } + catch (std::logic_error err) { + hasThrown = true; + printLine(err.what()); + } } } -- cgit v1.3.1-23-gd82d