File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,18 @@ void WriteDump::command(int narg, char **arg)
57
57
dumpargs[2 ] = arg[1 ]; // dump style
58
58
dumpargs[3 ] = utils::strdup (std::to_string (dumpfreq)); // dump frequency
59
59
60
- // delete existing dump with same ID to avoid re-use of dump-ID error
61
-
62
- auto *dump = output->get_dump_by_id (dump_id);
63
- if (dump) output->delete_dump (dump_id);
64
-
65
60
for (int i = 2 ; i < modindex; ++i) dumpargs[i + 2 ] = arg[i];
66
61
67
- dump = output->add_dump (modindex + 2 , dumpargs);
68
- if (modindex < narg) dump->modify_params (narg - modindex - 1 , &arg[modindex + 1 ]);
62
+ auto *dump = output->add_dump (modindex + 2 , dumpargs);
63
+
64
+ try {
65
+ if (modindex < narg) dump->modify_params (narg - modindex - 1 , &arg[modindex + 1 ]);
66
+ } catch (LAMMPSException &e) {
67
+ // delete dump after error and then rethrow the exception to avoid re-use of dump-ID error
68
+ dump = output->get_dump_by_id (dump_id);
69
+ if (dump) output->delete_dump (dump_id);
70
+ throw e;
71
+ }
69
72
70
73
// write out one frame and then delete the dump again
71
74
// set multifile_override for DumpImage so that filename needs no "*"
You can’t perform that action at this time.
0 commit comments