parser:: error handling now uses exceptions

This commit is contained in:
Zeno Rogue committed 2019-12-23 21:44:51 +01:00
1 parent a83220c34e
commit 15000034fd
6 files changed
+63 -29

No files matched your search

+9 -1
View File
@@ -79,7 +79,15 @@ EX namespace arg {
EX const char* argcs() { return args().c_str(); }
EX int argi() { return atoi(argcs()); }
EX unsigned arghex() { return strtoll(argcs(), NULL, 16); }
EX ld argf() { return parseld(args()); }
EX ld argf() {
try {
return parseld(args());
}
catch(hr_parse_exception& ex) {
println(hlog, "error parsing commandline parameters: ", ex.s);
exit(1);
}
}
EX bool argis(const string& s) { if(args()[0] == '-' && args()[1] == '-') return args().substr(1) == s; return args() == s; }
EX void shift_arg_formula(ld& x, const reaction_t& r IS(reaction_t())) {