Enable exceptions to save/restore information in a python dictionary and enable throwing exception from dictionary information

This commit is contained in:
Abdullah Tahiri
2017-05-12 22:40:05 +02:00
committed by wmayer
parent 085acfac5e
commit 3a27e2d8ff
6 changed files with 127 additions and 89 deletions

View File

@@ -42,15 +42,22 @@ void ExceptionFactory::Destruct (void)
_pcSingleton = 0;
}
void ExceptionFactory::raiseException (const ExceptionInfo& info) const
void ExceptionFactory::raiseException (PyObject * pydict) const
{
if(this->CanProduce(info.exceptionname.c_str())) {
std::string classname;
PyObject *pystring;
std::map<const std::string, AbstractProducer*>::const_iterator pProd;
pystring = PyDict_GetItemString(pydict,"sclassname");
pProd = _mpcProducers.find(info.exceptionname.c_str());
if (pProd != _mpcProducers.end())
static_cast<AbstractExceptionProducer *>(pProd->second)->raiseException(info);
if(pystring!=NULL) {
classname = std::string(PyString_AsString(pystring));
std::map<const std::string, AbstractProducer*>::const_iterator pProd;
pProd = _mpcProducers.find(classname.c_str());
if (pProd != _mpcProducers.end())
static_cast<AbstractExceptionProducer *>(pProd->second)->raiseException(pydict);
}
}