From 9c4bd366b62c72ddd3a77af61d22b44b87c13644 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Mon, 21 Sep 2020 12:26:32 +0200 Subject: [PATCH] added catch handler for syntax error when processing file args, for a clear error message with line number included --- main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.cpp b/main.cpp index e50f44a..8176e4e 100644 --- a/main.cpp +++ b/main.cpp @@ -77,6 +77,10 @@ int main(int argc, const char * argv[]) { done = false; std::ifstream file {argv[i]}; proc.eval(file, done); + } catch (const syntax_error& err) { + std::cerr << "curly: syntax error in " << argv[i]; + std::cerr << ", at line " << err.lineno(); + std::cerr << ": " << err.what() << '\n'; } catch (const std::runtime_error& ex) { std::cerr << "curly: " << ex.what() << '\n'; }