From e897ab76116c0f78cf356e17d16b425dfc297b48 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 4 May 2022 16:21:17 -0400 Subject: [PATCH] improve error messages --- src/output.cpp | 21 ++++++++++----------- unittest/commands/test_simple_commands.cpp | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/output.cpp b/src/output.cpp index 9444164b63..26944d6e5b 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -744,11 +744,11 @@ void Output::add_dump(int narg, char **arg) for (int idump = 0; idump < ndump; idump++) if (strcmp(arg[0],dump[idump]->id) == 0) - error->all(FLERR,"Reuse of dump ID"); + error->all(FLERR,"Reuse of dump ID: {}", arg[0]); int igroup = group->find(arg[1]); - if (igroup == -1) error->all(FLERR,"Could not find dump group ID"); + if (igroup == -1) error->all(FLERR,"Could not find dump group ID: {}", arg[1]); if (utils::inumeric(FLERR,arg[3],false,lmp) <= 0) - error->all(FLERR,"Invalid dump frequency"); + error->all(FLERR,"Invalid dump frequency {}", arg[3]); // extend Dump list if necessary @@ -794,14 +794,14 @@ void Output::add_dump(int narg, char **arg) void Output::modify_dump(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 1) utils::missing_cmd_args(FLERR, "dump_modify",error); // find which dump it is int idump; for (idump = 0; idump < ndump; idump++) if (strcmp(arg[0],dump[idump]->id) == 0) break; - if (idump == ndump) error->all(FLERR,"Cound not find dump_modify ID"); + if (idump == ndump) error->all(FLERR,"Could not find dump_modify ID: {}", arg[0]); dump[idump]->modify_params(narg-1,&arg[1]); } @@ -817,7 +817,7 @@ void Output::delete_dump(char *id) int idump; for (idump = 0; idump < ndump; idump++) if (strcmp(id,dump[idump]->id) == 0) break; - if (idump == ndump) error->all(FLERR,"Could not find undump ID"); + if (idump == ndump) error->all(FLERR,"Could not find undump ID: {}", id); delete dump[idump]; delete[] var_dump[idump]; @@ -871,7 +871,7 @@ void Output::set_thermo(int narg, char **arg) var_thermo = utils::strdup(arg[0]+2); } else { thermo_every = utils::inumeric(FLERR,arg[0],false,lmp); - if (thermo_every < 0) error->all(FLERR,"Illegal thermo command"); + if (thermo_every < 0) error->all(FLERR,"Illegal thermo output frequency {}", thermo_every); } } @@ -881,7 +881,7 @@ void Output::set_thermo(int narg, char **arg) void Output::create_thermo(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal thermo_style command"); + if (narg < 1) utils::missing_cmd_args(FLERR, "thermo_style", error); // don't allow this so that dipole style can safely allocate inertia vector @@ -891,8 +891,7 @@ void Output::create_thermo(int narg, char **arg) // warn if previous thermo had been modified via thermo_modify command if (thermo->modified && comm->me == 0) - error->warning(FLERR,"New thermo_style command, " - "previous thermo_modify settings will be lost"); + error->warning(FLERR,"New thermo_style command, previous thermo_modify settings will be lost"); // set thermo = nullptr in case new Thermo throws an error @@ -908,7 +907,7 @@ void Output::create_thermo(int narg, char **arg) void Output::create_restart(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal restart command"); + if (narg < 1) utils::missing_cmd_args(FLERR, "restart", error); int every = 0; int varflag = 0; diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index ddedae4e9a..513f04b745 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -340,7 +340,7 @@ TEST_F(SimpleCommandsTest, Thermo) ASSERT_EQ(lmp->output->var_thermo, nullptr); TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo");); - TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo -1");); + TEST_FAILURE(".*ERROR: Illegal thermo output frequency.*", command("thermo -1");); TEST_FAILURE(".*ERROR: Expected integer.*", command("thermo xxx");); }