add info about %catches, while we define if we need a better name

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8369 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-11 02:03:37 +00:00
commit 98a0beb245

View file

@ -3693,9 +3693,10 @@ public:
</div> </div>
<p> <p>
If an exception specification is used, SWIG automatically generates wrapper code for catching the If an exception specification is used, SWIG automatically generates
indicated exception and converting it into an error in the target language. In certain language wrapper code for catching the indicated exception and, when possible,
modules, wrapped exception classes themselves can be used to catch errors. For example, in Python, you can rethrowing it into the target language, or converting it into an error
in the target language otherwise. For example, in Python, you can
write code like this: write code like this:
</p> </p>
@ -3719,6 +3720,46 @@ properly handle C++ exceptions. To do that, a different set of special SWIG dire
Consult the "<a href="Customization.html#Customization">Customization features</a>" chapter for details. Consult the "<a href="Customization.html#Customization">Customization features</a>" chapter for details.
</p> </p>
<p>
Additionally, since SWIG 1.3.28, it is possible to use the
<tt>%catches</tt> directive to define the desired "catch list". For
example, if you have
</p>
<div class="code">
<pre>
class EBase
class Error1 : EBase { };
class Error2 : EBase { };
class Error3 : EBase { };
class Error4 : EBase { };
%catches(EBase) Foo::blah();
%catches(Error1,Error2,...) Foo::bar();
class Foo {
public:
...
void blah() throw(Error1,Error2,Error3,Error4);
void bar();
...
};
</pre>
</div>
<p>
For the method <tt> Foo::blah() </tt> SWIG will catch (and try to
rethrow) only the base part of the exceptions, <tt>EBase</tt>, and not
the entire list specified in via the throw statement, i.e., <tt> Error1,Error2,Error3,Error4</tt>.
</p>
<p> For the <tt> Foo::bar() </tt> method, which can throw anything,
SWIG will try to catch and rethrow <tt> Error1</tt> and
<tt>Error2</tt>, while any other exceptions will be caught by the
anonymous specification "..." and treated as an unknown exception.
</p>
<H2><a name="SWIGPlus_nn33"></a>6.21 Pointers to Members</H2> <H2><a name="SWIGPlus_nn33"></a>6.21 Pointers to Members</H2>