MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / getMessage

Function getMessage

extensions/jni/JavaException.h:63–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61};
62
63static std::string getMessage(JNIEnv *env, jthrowable throwable) {
64
65 jclass clazz = env->FindClass("java/lang/Throwable");
66
67 jmethodID getMessage = env->GetMethodID(clazz, "toString", "()Ljava/lang/String;");
68 if (getMessage == nullptr) {
69 return "";
70 }
71 jstring message = (jstring) env->CallObjectMethod(throwable, getMessage);
72 if (env->ExceptionOccurred()) {
73 env->ExceptionClear();
74 return JVM_ERROR_MSG;
75 }
76 if (message) {
77 // do whatever with mstr
78 std::string excp = JniStringToUTF(env, message);
79 env->DeleteLocalRef(message);
80 env->DeleteLocalRef(clazz);
81 return excp;
82 }
83 return "";
84}
85
86/**
87 * Static function to throw the exception if one exists within the ENV.

Callers 1

ThrowIfFunction · 0.85

Calls 1

JniStringToUTFFunction · 0.85

Tested by

no test coverage detected