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?
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to