[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] SIP default exception handler
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2009-10-30 19:16:07
Message-ID: 870bebf6d6c11aeef8361ba1b7ac1d8e () localhost
[Download RAW message or body]

On Thu, 29 Oct 2009 10:08:33 +0100, Sébastien Petitdemange
<sebastien.petitdemange@esrf.fr> wrote:
> Hi,
> 
> We are developing a C++ library that uses a single exception class
> (Exception) for throwing errors.
> 
> When wrapping the library with sip, we use the -e command line to
> activate the try/catch code on each C++ call.
> 
> However, our C++ code does not include the "throw(Exception)" modifier
> on each class method, because virtually any method can throw this
> exception, and it would be quite heavy to add it on every declaration.
> 
> In this scenario, sip (v4.7.9) just include a default try {} catch (...)
> { sipRaiseUnknownException }, so Python reports "Exception: Unknown".
> 
> Is there a way to specify a default exception handler to sip, so the
> generated code in this case would like something like:
> 
>   try {
>       // C++ call
>   } catch (OurDefaultException& e) {
>       ...
>       sipRaiseClassException(sipclass_OurDefaultException ... );
>   } catch (...) {
>       sipRaiseUnknownException();
>   }

I've added support for a /Default/ exception annotation in tonight's
snapshot. Untested - let me know if it's not quite right.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic