have Error::set_show_error() return the previous setting
This commit is contained in:
@ -20,6 +20,7 @@ functions. They do not directly call the LAMMPS library.
|
||||
- :cpp:func:`lammps_force_timeout`
|
||||
- :cpp:func:`lammps_has_error`
|
||||
- :cpp:func:`lammps_get_last_error_message`
|
||||
- :cpp:func:`lammps_set_show_error`
|
||||
- :cpp:func:`lammps_python_api_version`
|
||||
|
||||
The :cpp:func:`lammps_free` function is a clean-up function to free
|
||||
@ -110,6 +111,11 @@ where such memory buffers were allocated that require the use of
|
||||
|
||||
-----------------------
|
||||
|
||||
.. doxygenfunction:: lammps_set_show_error
|
||||
:project: progguide
|
||||
|
||||
-----------------------
|
||||
|
||||
.. doxygenfunction:: lammps_python_api_version
|
||||
:project: progguide
|
||||
|
||||
|
||||
@ -348,6 +348,7 @@ class lammps(object):
|
||||
self.lib.lammps_get_last_error_message.argtypes = [c_void_p, c_char_p, c_int]
|
||||
self.lib.lammps_get_last_error_message.restype = c_int
|
||||
self.lib.lammps_set_show_error.argtypes = [c_void_p, c_int]
|
||||
self.lib.lammps_set_show_error.restype = c_int
|
||||
|
||||
self.lib.lammps_extract_global.argtypes = [c_void_p, c_char_p]
|
||||
self.lib.lammps_extract_global_datatype.argtypes = [c_void_p, c_char_p]
|
||||
@ -2139,6 +2140,8 @@ class lammps(object):
|
||||
|
||||
:param flag: enable (1) or disable (0) printing of error message
|
||||
:type flag: int
|
||||
:return: previous setting of the flag
|
||||
:rtype: int
|
||||
"""
|
||||
self.lib.lammps_set_show_error(self.lmp, flag)
|
||||
|
||||
|
||||
@ -315,9 +315,12 @@ void Error::set_last_error(const char *msg, ErrorType type)
|
||||
/* ----------------------------------------------------------------------
|
||||
enable or disable printing error messages. for use with library interface.
|
||||
if flag = 0 only last error message and type are updated.
|
||||
returns the previous setting.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Error::set_show_error(const int flag)
|
||||
int Error::set_show_error(const int flag)
|
||||
{
|
||||
int oldflag = show_error
|
||||
showerror = flag;
|
||||
return oldflag;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class Error : protected Pointers {
|
||||
std::string get_last_error() const;
|
||||
ErrorType get_last_error_type() const;
|
||||
void set_last_error(const char *msg, ErrorType type = ERROR_NORMAL);
|
||||
void set_show_error(const int flag);
|
||||
int set_show_error(const int flag);
|
||||
|
||||
private:
|
||||
std::string last_error_message;
|
||||
|
||||
@ -7342,17 +7342,21 @@ This function can be used to stop LAMMPS from printing error messages
|
||||
it may be left to the code calling the library interface whether to
|
||||
check for them, and retrieve and print error messages using the library
|
||||
interface functions :cpp:func:`lammps_has_error` and
|
||||
:cpp:func:`lammps_get_last_error_message`.
|
||||
:cpp:func:`lammps_get_last_error_message`. The function returns the
|
||||
previous setting so that one can easily override the setting
|
||||
temporarily and restore it afterwards.
|
||||
|
||||
\endverbatim
|
||||
*
|
||||
* \param handle pointer to a previously created LAMMPS instance cast to ``void *`` or NULL
|
||||
* \param flag enable (not 0) or disable (0) printing error messages before throwing exception
|
||||
* \return previous setting of the flag
|
||||
*/
|
||||
void lammps_set_show_error(void *handle, const int flag)
|
||||
int lammps_set_show_error(void *handle, const int flag)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
if (lmp && lmp->error) lmp->error->set_show_error(flag);
|
||||
if (lmp && lmp->error) return lmp->error->set_show_error(flag);
|
||||
return 1; // default value
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -312,7 +312,7 @@ void lammps_force_timeout(void *handle);
|
||||
|
||||
int lammps_has_error(void *handle);
|
||||
int lammps_get_last_error_message(void *handle, char *buffer, int buf_size);
|
||||
void lammps_set_show_error(void *handle, const int flag);
|
||||
int lammps_set_show_error(void *handle, const int flag);
|
||||
|
||||
int lammps_python_api_version();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user