From a57b759af9a216efdc065e2e7cd39d95b72ebe36 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Wed, 15 Nov 2023 15:44:42 +0100 Subject: [PATCH] Main: catch errors --- src/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ecfef8c..45e511a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,10 +36,18 @@ int main(int argc, char* argv[]) { EvalResult res = eval(ast); cout << get(res) << endl; + } catch (const TokenError& e) { + pretty_print_error(input, e.pos); + cout << BOLD RED "Token Error: " RESET << e.what() << endl; + } catch (const SyntaxError& e) { pretty_print_error(input, e.pos); cout << BOLD RED "Syntax Error: " RESET << e.what() << endl; + } catch (const RuntimeError& e) { + pretty_print_error(input, e.pos); + cout << BOLD RED "Runtime Error: " RESET << e.what() << endl; + } catch (const ParseException& e) { cout << RED "ParsingError" RESET << endl; }