hd-rum-transcode: catch stoi invalid_argument

Make something like `hd-rum-transcode 8M 5004 -P x 100::1` fail with
humaan readable message.
This commit is contained in:
Martin Pulec
2024-05-17 13:51:38 +02:00
parent 6e8f20bcea
commit aaf783ecfe

View File

@@ -1016,6 +1016,13 @@ int main(int argc, char **argv)
int ret = -1;
try {
ret = parse_fmt(argc, argv, &params);
} catch (invalid_argument &e) {
if (strcmp(e.what(), "stoi") != 0 &&
strcmp(e.what(), "stod") != 0) {
throw;
}
MSG(ERROR, "Non-numeric value passed to option "
"expecting a number!\n");
} catch (ug_runtime_error &e) {
MSG(FATAL, "%s\n", e.what());
}