Base: improve exception

For better FC and Python exception mapping.
This commit is contained in:
Zheng, Lei
2019-06-21 10:46:43 +08:00
committed by wmayer
parent ea8965cbc2
commit 8f16147a40
9 changed files with 311 additions and 110 deletions

View File

@@ -194,6 +194,7 @@ Base::ConsoleObserverFile *Application::_pConsoleObserverFile =0;
AppExport std::map<std::string,std::string> Application::mConfig;
BaseExport extern PyObject* Base::BaseExceptionFreeCADError;
BaseExport extern PyObject* Base::BaseExceptionFreeCADAbort;
//**************************************************************************
// Construction and destruction
@@ -314,6 +315,10 @@ Application::Application(std::map<std::string,std::string> &mConfig)
Py_INCREF(Base::BaseExceptionFreeCADError);
PyModule_AddObject(pBaseModule, "FreeCADError", Base::BaseExceptionFreeCADError);
Base::BaseExceptionFreeCADAbort = PyErr_NewException("Base.FreeCADAbort", PyExc_BaseException, NULL);
Py_INCREF(Base::BaseExceptionFreeCADAbort);
PyModule_AddObject(pBaseModule, "FreeCADAbort", Base::BaseExceptionFreeCADAbort);
// Python types
Base::Interpreter().addType(&Base::VectorPy ::Type,pBaseModule,"Vector");
Base::Interpreter().addType(&Base::MatrixPy ::Type,pBaseModule,"Matrix");
@@ -1319,6 +1324,7 @@ void Application::initTypes(void)
Base::Type ::init();
Base::BaseClass ::init();
Base::Exception ::init();
Base::AbortException ::init();
Base::Persistence ::init();
// Complex data classes
@@ -1461,6 +1467,8 @@ void Application::initTypes(void)
new ExceptionProducer<Base::TypeError>;
new ExceptionProducer<Base::ValueError>;
new ExceptionProducer<Base::IndexError>;
new ExceptionProducer<Base::NameError>;
new ExceptionProducer<Base::ImportError>;
new ExceptionProducer<Base::AttributeError>;
new ExceptionProducer<Base::RuntimeError>;
new ExceptionProducer<Base::BadGraphError>;