[PyQt] Raising C++ exceptions from python
Alessandro Pasotti
apasotti at gmail.com
Mon Oct 13 08:48:53 BST 2014
Hello,
What is the recommended way to raise/throw a C++ exception from python
to be catched in C++ code?
For example, I have this SIP code:
class QgsMapServiceException
{
%TypeHeaderCode
#include <qgsmapserviceexception.h>
%End
public:
QgsMapServiceException( const QString& code, const QString& message );
QString code() const;
QString message() const;
};
In python code I would like to raise this exception and catch it from
C++ FCGI loop.
The problem is that Python doesn't know that QgsMapServiceException is
an exception:
raise QgsMapServiceException('ExceptionFilter', 'Test exception
raised from ExceptionFilter')
TypeError: exceptions must be old-style classes or derived from
BaseException, not QgsMapServiceException
--
Alessandro Pasotti
w3: www.itopen.it
More information about the PyQt
mailing list