1 Jul 2005 08:55
Re: Handling exceptions in SIP
Denis S. Otkidach <ods <at> strana.ru>
2005-07-01 06:55:30 GMT
2005-07-01 06:55:30 GMT
On Thu, 30 Jun 2005 17:24:27 +0100
Phil Thompson <phil <at> riverbankcomputing.co.uk> wrote:
> > 4) There are several standard exceptions which I always have to catch.
> > Now I have a macro for them:
> >
> > #define CATCH_STD_EXCEPTIONS \
> > catch (std::bad_alloc&) {\
> > PyErr_NoMemory(); \
> > sipIsErr = 1; \
> > } catch (std::exception &exc) {\
> > PyErr_SetString(PyExc_RuntimeError, exc.what()); \
> > sipIsErr = 1; \
> > } catch (...) {\
> > PyErr_SetString(PyExc_RuntimeError, "unknown"); \
> > sipIsErr = 1; \
> > }
> >
> > used in %MethodCode:
> >
> > %MethodCode
> > try {
> > sipRes = someMethod(...);
> > } CATCH_STD_EXCEPTIONS // sipIsErr - this comment is important hint to
> > SIP! %End
>
> If your point is the need for the comment, then yes - consider it a feature.
No, I meant these exceptions must be caught almost everywhere. So I
have to add %MethodCode to almost every method, which is annoying. The
(Continue reading)
RSS Feed