throw std::logic_error instead of aborting the process and convert to java exception

Summary: Changelog: [Internal][Yoga] throw std::logic_error instead of aborting the process and convert to java exception for jni layer

Reviewed By: pasqualeanatriello

Differential Revision: D21301235

fbshipit-source-id: 148b27920e62990a271e1d0df8c85a2cc42f4fd4
This commit is contained in:
Sidharth Guglani
2020-05-14 06:32:13 -07:00
committed by Facebook GitHub Bot
parent ac7c85c0a6
commit 07c0d539bd
6 changed files with 18 additions and 9 deletions

View File

@@ -388,6 +388,13 @@ static void jni_YGNodeCalculateLayoutJNI(
if (throwable.get()) {
env->Throw(throwable.get());
}
} catch (const std::logic_error& ex) {
env->ExceptionClear();
jclass cl = env->FindClass("Ljava/lang/IllegalStateException;");
static const jmethodID methodId = facebook::yoga::vanillajni::getMethodId(
env, cl, "<init>", "(Ljava/lang/String;)V");
auto throwable = env->NewObject(cl, methodId, env->NewStringUTF(ex.what()));
env->Throw(static_cast<jthrowable>(throwable));
}
}