Python gmxapi exception hierarchy - Redmine #3034
libgmxapi
can throw exceptions derived from gmxapi::Exception
,
defined in the gmxapi/exceptions.h installed header. These exceptions
should have bindings in the gmxapi Python package (in the _gmxapi
C extension module) so that they are
easily catchable from Python.
Should C exceptions defined in the
_gmxapi
module should derive from gmxapi::Exception
?
Is it a priority that users of the Python package should be able to use
gmxapi.exceptions.Error
as a catch-all base exception, even for
exceptions originating in the _gmxapi extension module or in the core
GROMACS library?
Developer documentation should describe how exceptions propagate and how they are catchable in both directions between Python and C, with explanations of caveats for exceptions originating in different binaries or Python packages.
Also reference prior discussion at https://github.com/kassonlab/gmxapi/issues/125
(from redmine: issue id 3034, created on 2019-07-12 by eirrgang, closed on 2019-10-13)
- Relations:
- relates #701 (closed)
- relates #988 (closed)
- relates #2045 (closed)
- Changesets:
- Revision 6b9c1965 by Eric Irrgang on 2019-08-13T09:04:50Z:
Map gmxapi C++ exceptions to Python exceptions.
Create a base exception and several derived exceptions in the
gmxapi._gmxapi C++ extension module for the Python package. In addition
to mapping the few existing exceptions from gmxapi/exceptions.h, we add
handlers for unmapped exceptions derived from gmxapi::Exception and for
unknown exceptions, such as exceptions originating in the core library
or uncaught stdlib exceptions. gmxapi._gmxapi.Exception derives from
gmxapi.exceptions.Error.
Refs #3034
Change-Id: I270908216271876bcb8ef6e83b78ca333042c336