move timespec2seconds exception handling to calling function

This commit is contained in:
Axel Kohlmeyer
2025-01-12 17:48:20 -05:00
parent 60b10c1588
commit 943504fd98
2 changed files with 12 additions and 10 deletions

View File

@ -15,6 +15,7 @@
#include "comm.h" #include "comm.h"
#include "error.h" #include "error.h"
#include "tokenizer.h"
#include "fmt/chrono.h" #include "fmt/chrono.h"
#include <cstring> #include <cstring>
@ -231,9 +232,14 @@ void Timer::modify_params(int narg, char **arg)
} else if (strcmp(arg[iarg], "timeout") == 0) { } else if (strcmp(arg[iarg], "timeout") == 0) {
++iarg; ++iarg;
if (iarg < narg) { if (iarg < narg) {
_timeout = utils::timespec2seconds(arg[iarg]); try {
} else _timeout = utils::timespec2seconds(arg[iarg]);
error->all(FLERR, "Illegal timer command"); } catch (TokenizerException &) {
error->all(FLERR, "Illegal timeout time: {}", arg[iarg]);
}
} else {
utils::missing_cmd_args(FLERR, "timer timeout", error);
}
} else if (strcmp(arg[iarg], "every") == 0) { } else if (strcmp(arg[iarg], "every") == 0) {
++iarg; ++iarg;
if (iarg < narg) { if (iarg < narg) {

View File

@ -1744,13 +1744,9 @@ double utils::timespec2seconds(const std::string &timespec)
ValueTokenizer values(timespec, ":"); ValueTokenizer values(timespec, ":");
try { for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++) { if (!values.has_next()) break;
if (!values.has_next()) break; vals[i] = values.next_double();
vals[i] = values.next_double();
}
} catch (TokenizerException &) {
return -1.0;
} }
if (i == 3) if (i == 3)