added catch handler for syntax error when processing file args, for a clear error message with line number included

This commit is contained in:
Bob Polis 2020-09-21 12:26:32 +02:00
parent 372bc976a0
commit 9c4bd366b6

View File

@ -77,6 +77,10 @@ int main(int argc, const char * argv[]) {
done = false; done = false;
std::ifstream file {argv[i]}; std::ifstream file {argv[i]};
proc.eval(file, done); 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) { } catch (const std::runtime_error& ex) {
std::cerr << "curly: " << ex.what() << '\n'; std::cerr << "curly: " << ex.what() << '\n';
} }