Add exception handling in vanilla jni

Summary:
Exception handling in vanilla jni

## Changelog:
[Internal] [Added] Added exception handling for vanilla jni implementation in yoga

Reviewed By: amir-shalem

Differential Revision: D18036134

fbshipit-source-id: 965eaa2fddbc00b9ac0120b79678608e280d03db
This commit is contained in:
Sidharth Guglani
2019-10-22 10:45:20 -07:00
committed by Facebook Github Bot
parent 42bba10894
commit 688bd4ef72
3 changed files with 195 additions and 22 deletions

View File

@@ -62,12 +62,16 @@ void logErrorMessageAndDie(const char* message) {
}
void assertNoPendingJniException(JNIEnv* env) {
// This method cannot call any other method of the library, since other
// methods of the library use it to check for exceptions too
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
logErrorMessageAndDie("Aborting due to pending Java exception in JNI");
if (env->ExceptionCheck() == JNI_FALSE) {
return;
}
auto throwable = env->ExceptionOccurred();
if (!throwable) {
logErrorMessageAndDie("Unable to get pending JNI exception.");
}
env->ExceptionClear();
throw throwable;
}
} // namespace vanillajni