From 1098ca87491746211e4580a7bc66c3b4b8db0785 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 7 Oct 2020 13:08:49 -0400 Subject: [PATCH] add some more explanation about exceptions from the library interface perspective --- src/library.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/library.cpp b/src/library.cpp index cad0e4d20f..4a6919f8c4 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4313,6 +4313,17 @@ int lammps_config_has_ffmpeg_support() { In case of errors LAMMPS will either abort or throw a C++ exception. The latter has to be :ref:`enabled at compile time `. This function checks if exceptions were enabled. + +When using the library interface and C++ exceptions are enabled, +the library interface functions will "catch" them and the +error status can then be checked by calling +:cpp:func:`lammps_has_error` and the most recent error message +can be retrieved via :cpp:func:`lammps_get_last_error_message`. +This can allow to restart a calculation or delete and recreate +the LAMMPS instance when C++ exceptions are enabled. One application +of using exceptions this way is the :ref:`lammps_shell`. If C++ +exceptions are disabled and an error happens during a call to +LAMMPS, the application will terminate. \endverbatim * \return 1 if yes, otherwise 0 */