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:
committed by
Facebook GitHub Bot
parent
ac7c85c0a6
commit
07c0d539bd
@@ -65,3 +65,7 @@ YGFloatOptional YGFloatOptionalMax(YGFloatOptional op1, YGFloatOptional op2) {
|
||||
}
|
||||
return op1.isUndefined() ? op2 : op1;
|
||||
}
|
||||
|
||||
void throwLogicalErrorWithMessage(const char* message) {
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
|
@@ -141,3 +141,5 @@ inline YGFloatOptional YGResolveValueMargin(
|
||||
const float ownerSize) {
|
||||
return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
|
||||
}
|
||||
|
||||
void throwLogicalErrorWithMessage(const char* message);
|
||||
|
@@ -249,9 +249,6 @@ YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
||||
static YGConfigRef YGConfigClone(const YGConfig& oldConfig) {
|
||||
const YGConfigRef config = new YGConfig(oldConfig);
|
||||
YGAssert(config != nullptr, "Could not allocate memory for config");
|
||||
if (config == nullptr) {
|
||||
abort();
|
||||
}
|
||||
gConfigInstanceCount++;
|
||||
return config;
|
||||
}
|
||||
@@ -4341,6 +4338,7 @@ YOGA_EXPORT void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
void YGAssert(const bool condition, const char* message) {
|
||||
if (!condition) {
|
||||
Log::log(YGNodeRef{nullptr}, YGLogLevelFatal, nullptr, "%s\n", message);
|
||||
throwLogicalErrorWithMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4350,6 +4348,7 @@ void YGAssertWithNode(
|
||||
const char* message) {
|
||||
if (!condition) {
|
||||
Log::log(node, YGLogLevelFatal, nullptr, "%s\n", message);
|
||||
throwLogicalErrorWithMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4359,6 +4358,7 @@ void YGAssertWithConfig(
|
||||
const char* message) {
|
||||
if (!condition) {
|
||||
Log::log(config, YGLogLevelFatal, nullptr, "%s\n", message);
|
||||
throwLogicalErrorWithMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,10 +26,6 @@ void vlog(
|
||||
va_list args) {
|
||||
YGConfig* logConfig = config != nullptr ? config : YGConfigGetDefault();
|
||||
logConfig->log(logConfig, node, level, context, format, args);
|
||||
|
||||
if (level == YGLogLevelFatal) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user