try to catch format errors from fmtlib
This commit is contained in:
@ -52,8 +52,11 @@ Error::Error(LAMMPS *lmp) : Pointers(lmp) {
|
|||||||
void Error::universe_all(const std::string &file, int line, const std::string &str)
|
void Error::universe_all(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
MPI_Barrier(universe->uworld);
|
MPI_Barrier(universe->uworld);
|
||||||
std::string mesg = fmt::format("ERROR: {} ({}:{})\n",
|
std::string mesg = "ERROR: " + str;
|
||||||
str,truncpath(file),line);
|
try {
|
||||||
|
mesg += fmt::format(" ({}:{})\n",truncpath(file),line);
|
||||||
|
} catch (fmt::format_error &e) {
|
||||||
|
}
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
|
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
|
||||||
if (universe->ulogfile) fputs(mesg.c_str(),universe->ulogfile);
|
if (universe->ulogfile) fputs(mesg.c_str(),universe->ulogfile);
|
||||||
@ -135,9 +138,14 @@ void Error::all(const std::string &file, int line, const std::string &str)
|
|||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
|
std::string mesg = "ERROR: " + str;
|
||||||
if (input && input->line) lastcmd = input->line;
|
if (input && input->line) lastcmd = input->line;
|
||||||
utils::logmesg(lmp,fmt::format("ERROR: {} ({}:{})\nLast command: {}\n",
|
try {
|
||||||
str,truncpath(file),line,lastcmd));
|
mesg += fmt::format(" ({}:{})\nLast command: {}\n",
|
||||||
|
truncpath(file),line,lastcmd);
|
||||||
|
} catch (fmt::format_error &e) {
|
||||||
|
}
|
||||||
|
utils::logmesg(lmp,mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
|
|||||||
@ -58,6 +58,10 @@ int main(int argc, char **argv)
|
|||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} catch(fmt::format_error &fe) {
|
||||||
|
fprintf(stderr,"fmt::format_error: %s\n", fe.what());
|
||||||
|
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD);
|
LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD);
|
||||||
|
|||||||
Reference in New Issue
Block a user