[PyQt] SIP: newbie question 3
Johan Råde
johan.rade at gmail.com
Thu Jul 7 08:16:28 BST 2011
Thanks for all the help! Here is a 3rd and last question.
Once I have figured this one out, I will be done porting my project from
boost.python to SIP.
I need to translate C++ exceptions to Python exceptions.
I have a function that does that:
void translate(const std::exception& e)
{
if(dynamic_cast<const FailedToOpenFile*>(&e))
PyErr_SetString(PyExc_IOError, e.what());
else if(dynamic_cast<const EndOfFile*>(&e))
PyErr_SetString(PyExc_EOFError, e.what());
...
}
Next I need to "apply" this function to all wrapped functions.
With boost.python I do that as follows:
boost::python::register_exception_translator<std::exception>(&translate);
With SWIG I do:
%exception {
try {
$action
} catch(const std::exception& e) {
translate(e);
return NULL;
}
}
How do I do that with SIP?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110707/826cd796/attachment.html>
More information about the PyQt
mailing list