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

@@ -25,20 +25,13 @@
#define BASE_EXCEPTIONFACTORY_H
#include <Python.h>
#include "Factory.h"
namespace Base
{
struct ExceptionInfo {
std::string exceptionname;
std::string function;
std::string message;
std::string file;
unsigned int line;
};
/// Abstract base class of all exception producers
class BaseExport AbstractExceptionProducer : public AbstractProducer
{
@@ -49,7 +42,7 @@ public:
void* Produce () const {
return nullptr;
}
virtual void raiseException(const ExceptionInfo& info) const = 0;
virtual void raiseException(PyObject * pydict) const = 0;
};
// --------------------------------------------------------------------
@@ -61,7 +54,7 @@ public:
static ExceptionFactory& Instance(void);
static void Destruct (void);
void raiseException(const ExceptionInfo& info) const;
void raiseException(PyObject * pydict) const;
private:
static ExceptionFactory* _pcSingleton;
@@ -83,13 +76,11 @@ public:
virtual ~ExceptionProducer (){}
void raiseException(const ExceptionInfo& info) const
void raiseException(PyObject * pydict) const
{
CLASS c;
c.setMessage(info.message);
c.setDebugInformation(info.file, info.line, info.function);
c.setPyDict(pydict);
throw c;
}