throwing Exception having multiple arguments in constructor
843829Mar 24 2007 — edited Mar 25 2007hi,
I am trying to implement exception handling for a JAVA + C++ module.
In which C++ exception is caught by a Java module.
The c++ code is as follows,
try
{
///////////===========
} catch (Exception1 &e) {
jclass clazz = jenv->FindClass("test/Exception1Java");
if(clazz)
jenv->ThrowNew(clazz,e.getErrMsg().c_str());
return 0;
} catch (Exception2 &e) {
jclass clazz = jenv->FindClass("test/Exception2");
if(clazz)
jenv->ThrowNew(clazz,e.getErrMsg().c_str());
return 0;
}
This works perfectly fine.
But I want to pass one more argument as int while throwing the java exception.
jenv->ThrowNew(clazz,e.getErrId(),e.getErrMsg().c_str());
As the jenv->ThrowNew function only take two arguments I am unable to send the error id( int ) to the message.
Is there any alternate to this function or some other approach to throw the java exceptions.