improve and modernize error messages

This commit is contained in:
Axel Kohlmeyer
2025-02-14 15:23:16 -05:00
parent d83121878e
commit 7f82dcd835
5 changed files with 20 additions and 16 deletions

View File

@ -262,11 +262,13 @@ void Modify::init()
for (i = 0; i < nfix; i++)
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup])
error->all(FLERR, "Fix {} does not allow use with a dynamic group", fix[i]->style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} does not allow use with a dynamic group",
fix[i]->style);
for (i = 0; i < ncompute; i++)
if (!compute[i]->dynamic_group_allow && group->dynamic[compute[i]->igroup])
error->all(FLERR, "Compute {} does not allow use with a dynamic group", compute[i]->style);
error->all(FLERR, Error::NOLASTLINE, "Compute {} does not allow use with a dynamic group",
compute[i]->style);
// warn if any particle is time integrated more than once
@ -834,13 +836,13 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
for (m = 0; exceptions[m] != nullptr; m++)
if (strcmp(arg[2], exceptions[m]) == 0) break;
if (exceptions[m] == nullptr)
error->all(FLERR, "Fix {} command before simulation box is defined", arg[2]);
error->all(FLERR, 2, "Fix {} command before simulation box is defined", arg[2]);
}
// check group ID
int igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR, "Could not find fix group ID {}", arg[1]);
if (igroup == -1) error->all(FLERR, 1, "Could not find fix group ID {}", arg[1]);
// if fix ID exists:
// set newflag = 0 so create new fix in same location in fix list
@ -874,7 +876,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
if (estyle == fix[ifix]->style) match = 1;
}
}
if (!match) error->all(FLERR, "Replacing a fix, but new style != old style");
if (!match) error->all(FLERR, 2, "Replacing a fix, but new style != old style");
if (fix[ifix]->igroup != igroup && comm->me == 0)
error->warning(FLERR, "Replacing a fix, but new group != old group");
@ -921,7 +923,8 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
fix[ifix] = fix_creator(lmp, narg, arg);
}
if (fix[ifix] == nullptr) error->all(FLERR, utils::check_packages_for_style("fix", arg[2], lmp));
if (fix[ifix] == nullptr)
error->all(FLERR, 2, utils::check_packages_for_style("fix", arg[2], lmp));
// increment nfix and update fix_list vector (if new)
@ -1244,7 +1247,8 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
// error check
if (get_compute_by_id(arg[0])) error->all(FLERR, "Reuse of compute ID '{}'", arg[0]);
if (get_compute_by_id(arg[0]))
error->all(FLERR, Error::ARGZERO, "Reuse of compute ID '{}'", arg[0]);
// extend Compute list if necessary