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