ExceptionDescribe - How to get the exception message as a string
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ramya_Priya
Posted On:   Wednesday, July 28, 2004 12:21 AM

When there is a JNI exception, ExceptionDescribe() by default writes the exception to stderr - which is mostly console. How will I get the exception message in a string buffer, so that I can write it to a file?
Please help

Re: ExceptionDescribe - How to get the exception message as a string

Posted By:   Anonymous  
Posted On:   Tuesday, October 12, 2004 10:59 AM

This will give you the message. Getting the stack trace is possible through a similar technique, but substantially more complex.


jthrowable e = env->ExceptionOccurred();
if (e != NULL)
{
env->ExceptionClear();

jmethodID toString = env->GetMethodID(env->FindClass("java/lang/Object"), "toString", "()Ljava/lang/String;");
jstring estring = (jstring) env->CallObjectMethod(e, toString);

jboolean isCopy;
message = env->GetStringUTFChars(estring, &isCopy);
}
About | Sitemap | Contact