Match convertRawProp error handling in iterator-based props parsing (#45156)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
Pieter De Baets
2024-06-26 03:46:25 -07:00
committed by Facebook GitHub Bot
parent 88a9b6e89f
commit 2dfb09c51a
@@ -110,15 +110,19 @@
struct, blockStart, prefix "BlockStart" suffix, rawValue)
// Rebuild a type that contains multiple fields from a single field value
#define REBUILD_FIELD_SWITCH_CASE( \
defaults, rawValue, property, field, fieldName) \
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
if ((rawValue).hasValue()) { \
decltype((defaults).field) res; \
fromRawValue(context, rawValue, res); \
(property).field = res; \
} else { \
(property).field = (defaults).field; \
} \
return; \
#define REBUILD_FIELD_SWITCH_CASE( \
defaults, rawValue, property, field, fieldName) \
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
if ((rawValue).hasValue()) [[likely]] { \
try { \
fromRawValue(context, rawValue, (property).field); \
} catch (const std::exception& e) { \
LOG(ERROR) << "Error while converting prop '" << fieldName \
<< "': " << e.what(); \
(property).field = (defaults).field; \
} \
} else { \
(property).field = (defaults).field; \
} \
return; \
}