separately catch exceptions thrown by new
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <mpi.h>
|
||||
#include <new>
|
||||
|
||||
#if defined(LAMMPS_TRAP_FPE) && defined(_GNU_SOURCE)
|
||||
#include <fenv.h>
|
||||
@ -89,6 +90,11 @@ int main(int argc, char **argv)
|
||||
finalize();
|
||||
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
exit(1);
|
||||
} catch (std::bad_alloc &ae) {
|
||||
fprintf(stderr, "C++ memory allocation failed: %s\n", ae.what());
|
||||
finalize();
|
||||
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
exit(1);
|
||||
} catch (std::exception &e) {
|
||||
fprintf(stderr, "Exception: %s\n", e.what());
|
||||
finalize();
|
||||
|
||||
Reference in New Issue
Block a user