Skip to content

Commit

Permalink
print exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
lgbo-ustc committed Apr 7, 2023
1 parent 5d0e686 commit 7add711
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/local-engine/jni/jni_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jbyteArray stringTojbyteArray(JNIEnv* env, const std::string & str);
{\
LOG_ERROR(&Poco::Logger::get("local_engine"), "Enter java exception handle.");\
auto throwable = (env)->ExceptionOccurred();\
jclass exceptionClass = (env)->FindClass("java/lang/Exception"); \
jmethodID getMessageMethod = (env)->GetMethodID(exceptionClass, "getMessage", "()Ljava/lang/String;"); \
jstring message = static_cast<jstring>((env)->CallObjectMethod(throwable, getMessageMethod)); \
const char *messageChars = (env)->GetStringUTFChars(message, NULL); \
LOG_ERROR(&Poco::Logger::get("jni"), "exception:{}", messageChars); \
(env)->ReleaseStringUTFChars(message, messageChars); \
(env)->Throw(throwable);\
}

Expand Down

0 comments on commit 7add711

Please sign in to comment.