Java director exception handling improvements
When a director method throws an exception and it is caught by DirectorException and passed back to Java using DirectorException::raiseJavaException, the Java stack trace now contains the original source line that threw the exception. Director exception handling code improved slightly to add some missing ExceptionClear calls before calling JNI code.
This commit is contained in:
parent
7d6808daab
commit
7aa28e37ec
7 changed files with 74 additions and 44 deletions
|
|
@ -42,7 +42,6 @@
|
|||
%feature("director:except") MyNS::Foo::ping {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear(); // clear java exception since mapping to c++ exception
|
||||
if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException1")) {
|
||||
throw 1;
|
||||
} else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException2")) {
|
||||
|
|
@ -71,7 +70,6 @@
|
|||
%feature("director:except") MyNS::Foo::pong %{
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
$directorthrowshandlers
|
||||
throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message());
|
||||
}
|
||||
|
|
@ -121,7 +119,10 @@
|
|||
%feature("director:except") MyNS::Foo::genericpong {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
if (Swig::ExceptionMatches(jenv,$error,"UnconstructableException")) {
|
||||
// Purposefully test NULL
|
||||
throw Swig::DirectorException(jenv, NULL);
|
||||
}
|
||||
throw Swig::DirectorException(jenv,$error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue