Base: Allow to also throw exception by given Python type

This commit is contained in:
wmayer
2025-03-22 14:44:15 +01:00
committed by Benjamin Nauck
parent 2c60e83f25
commit 231680c9ce
3 changed files with 37 additions and 8 deletions

View File

@@ -52,11 +52,16 @@ void ExceptionFactory::raiseException(PyObject* pydict) const
if (edict.hasKey("sclassname")) {
classname = static_cast<std::string>(Py::String(edict.getItem("sclassname")));
std::map<const std::string, AbstractProducer*>::const_iterator pProd;
pProd = _mpcProducers.find(classname);
auto pProd = _mpcProducers.find(classname);
if (pProd != _mpcProducers.end()) {
static_cast<AbstractExceptionProducer*>(pProd->second)->raiseException(pydict);
}
}
}
void ExceptionFactory::raiseExceptionByType(const PyExceptionData& data) const
{
for (const auto& it : _mpcProducers) {
static_cast<AbstractExceptionProducer*>(it.second)->raiseExceptionByType(data); // NOLINT
}
}