in native/src/error.c [82:126]
void tcn_ThrowAPRException(JNIEnv *e, apr_status_t err)
{
jclass aprErrorClass;
jmethodID constructorID = 0;
jobject throwObj;
jstring jdescription;
char serr[512] = {0};
aprErrorClass = (*e)->FindClass(e, TCN_ERROR_CLASS);
if (aprErrorClass == NULL) {
fprintf(stderr, "Cannot find " TCN_ERROR_CLASS " class\n");
return;
}
/* Find the constructor ID */
constructorID = (*e)->GetMethodID(e, aprErrorClass,
"<init>",
"(ILjava/lang/String;)V");
if (constructorID == NULL) {
fprintf(stderr,
"Cannot find constructor for " TCN_ERROR_CLASS " class\n");
goto cleanup;
}
apr_strerror(err, serr, 512);
/* Obtain the string objects */
jdescription = AJP_TO_JSTRING(serr);
if (jdescription == NULL) {
fprintf(stderr,
"Cannot allocate description for " TCN_ERROR_CLASS " class\n");
goto cleanup;
}
/* Create the APR Error object */
throwObj = (*e)->NewObject(e, aprErrorClass, constructorID,
(jint)err, jdescription);
if (throwObj == NULL) {
fprintf(stderr,
"Cannot allocate new " TCN_ERROR_CLASS " object\n");
goto cleanup;
}
(*e)->Throw(e, throwObj);
cleanup:
(*e)->DeleteLocalRef(e, aprErrorClass);
}