« Return to Thread: Using %attribute and %exception together

Using %attribute and %exception together

by Geoffrey Philbrick :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.

I am wrapping my get/set methods with an attribute/member for Python as follows:

 

%attribute(MyObject, double, value, get, set)

 

Prior to using %attribute I was handling exceptions thrown from the C++ MyObject::set like this:

 

%exception MyObject::set {

   try {

      $action

   } catch (RangeException &e) {

         PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));

         return NULL;

   }

}

 

This works fine without %attribute, but no longer works because the set method is called through this macro, thus the code to handle the exception is never inserted:

 

MyObject_value_set(arg1,arg2);

 

What is the correct way to use these two constructs together?

 

Thanks for any hints.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Using %attribute and %exception together

LightInTheBox - Buy quality products at wholesale price!