Skip to content

Commit 2dfb09c

Browse files
javachefacebook-github-bot
authored andcommitted
Match convertRawProp error handling in iterator-based props parsing (#45156)
Summary: Pull Request resolved: #45156 We don't want to bubble up exceptions from props parsing, so match the behaviour from convertRawProp and fall back to the default value when an exception is encountered. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D59000397 fbshipit-source-id: f6f64a80fed98525cdd2a5b5d360c2d6ede76a12
1 parent 88a9b6e commit 2dfb09c

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

  • packages/react-native/ReactCommon/react/renderer/core

‎packages/react-native/ReactCommon/react/renderer/core/PropsMacros.h‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@
110110
struct, blockStart, prefix "BlockStart" suffix, rawValue)
111111

112112
// Rebuild a type that contains multiple fields from a single field value
113-
#define REBUILD_FIELD_SWITCH_CASE( \
114-
defaults, rawValue, property, field, fieldName) \
115-
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
116-
if ((rawValue).hasValue()) { \
117-
decltype((defaults).field) res; \
118-
fromRawValue(context, rawValue, res); \
119-
(property).field = res; \
120-
} else { \
121-
(property).field = (defaults).field; \
122-
} \
123-
return; \
113+
#define REBUILD_FIELD_SWITCH_CASE( \
114+
defaults, rawValue, property, field, fieldName) \
115+
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
116+
if ((rawValue).hasValue()) [[likely]] { \
117+
try { \
118+
fromRawValue(context, rawValue, (property).field); \
119+
} catch (const std::exception& e) { \
120+
LOG(ERROR) << "Error while converting prop '" << fieldName \
121+
<< "': " << e.what(); \
122+
(property).field = (defaults).field; \
123+
} \
124+
} else { \
125+
(property).field = (defaults).field; \
126+
} \
127+
return; \
124128
}

0 commit comments

Comments
 (0)