Replace DirectorException::raiseJavaException with DirectorException::throwException
This is part of a plan to provide a common DirectorException api for throwing the target language exception raised during a director method call.
This commit is contained in:
parent
34712c0108
commit
901f8357b0
5 changed files with 17 additions and 10 deletions
|
|
@ -3992,7 +3992,7 @@ namespace Swig {
|
||||||
|
|
||||||
// Reconstruct and raise/throw the Java Exception that caused the DirectorException
|
// Reconstruct and raise/throw the Java Exception that caused the DirectorException
|
||||||
// Note that any error in the JNI exception handling results in a Java RuntimeException
|
// Note that any error in the JNI exception handling results in a Java RuntimeException
|
||||||
void raiseJavaException(JNIEnv *jenv) const;
|
void throwException(JNIEnv *jenv) const;
|
||||||
|
|
||||||
// Create and throw the DirectorException
|
// Create and throw the DirectorException
|
||||||
static void raise(JNIEnv *jenv, jthrowable throwable) {
|
static void raise(JNIEnv *jenv, jthrowable throwable) {
|
||||||
|
|
@ -4295,7 +4295,7 @@ SWIGEXPORT void JNICALL Java_exampleJNI_MyClass_1call_1dirmethod(JNIEnv *jenv, j
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
} catch(Swig::DirectorException &_e) {
|
} catch(Swig::DirectorException &_e) {
|
||||||
(&_e)->raiseJavaException(jenv);
|
(&_e)->throwException(jenv);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,10 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
||||||
try { $action }
|
try {
|
||||||
catch (Swig::DirectorException & direxcp) {
|
$action
|
||||||
direxcp.raiseJavaException(jenv); // jenv always available in JNI code
|
} catch (Swig::DirectorException & direxcp) {
|
||||||
|
direxcp.throwException(jenv); // jenv always available in JNI code
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,10 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
||||||
try { $action }
|
try {
|
||||||
catch (Swig::DirectorException & direxcp) {
|
$action
|
||||||
direxcp.raiseJavaException(jenv); // jenv always available in JNI code
|
} catch (Swig::DirectorException & direxcp) {
|
||||||
|
direxcp.throwException(jenv); // jenv always available in JNI code
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ namespace Swig {
|
||||||
|
|
||||||
// Reconstruct and raise/throw the Java Exception that caused the DirectorException
|
// Reconstruct and raise/throw the Java Exception that caused the DirectorException
|
||||||
// Note that any error in the JNI exception handling results in a Java RuntimeException
|
// Note that any error in the JNI exception handling results in a Java RuntimeException
|
||||||
void raiseJavaException(JNIEnv *jenv) const {
|
void throwException(JNIEnv *jenv) const {
|
||||||
if (jenv) {
|
if (jenv) {
|
||||||
if (jenv == jenv_ && throwable_) {
|
if (jenv == jenv_ && throwable_) {
|
||||||
// Throw original exception if not already pending
|
// Throw original exception if not already pending
|
||||||
|
|
@ -371,6 +371,11 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated - use throwException
|
||||||
|
void raiseJavaException(JNIEnv *jenv) const {
|
||||||
|
throwException(jenv);
|
||||||
|
}
|
||||||
|
|
||||||
// Create and throw the DirectorException
|
// Create and throw the DirectorException
|
||||||
static void raise(JNIEnv *jenv, jthrowable throwable) {
|
static void raise(JNIEnv *jenv, jthrowable throwable) {
|
||||||
throw DirectorException(jenv, throwable);
|
throw DirectorException(jenv, throwable);
|
||||||
|
|
|
||||||
|
|
@ -1053,7 +1053,7 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
|
||||||
|
|
||||||
/* For methods to raise/throw the original Java exception thrown in a director method */
|
/* For methods to raise/throw the original Java exception thrown in a director method */
|
||||||
%typemap(throws) Swig::DirectorException
|
%typemap(throws) Swig::DirectorException
|
||||||
%{ $1.raiseJavaException(jenv);
|
%{ $1.throwException(jenv);
|
||||||
return $null; %}
|
return $null; %}
|
||||||
|
|
||||||
/* Java to C++ DirectorException should already be handled. Suppress warning and do nothing in the
|
/* Java to C++ DirectorException should already be handled. Suppress warning and do nothing in the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue