catch JSON library exceptions
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
#include "input.h"
|
||||
#include "library.h"
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <mpi.h>
|
||||
#include <new>
|
||||
@ -30,6 +32,7 @@
|
||||
#include <mdi.h>
|
||||
#endif
|
||||
|
||||
using json = nlohmann_lmp::json;
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
// for convenience
|
||||
@ -90,6 +93,11 @@ int main(int argc, char **argv)
|
||||
finalize();
|
||||
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
exit(1);
|
||||
} catch (json::exception &je) {
|
||||
fprintf(stderr, "\nJSON library error %d: %s\n", je.id, je.what());
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user