Improve error messages when enum members are missing (#51502)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51502

While working on a case for Editor on mac, it took me a while to figure out what enum was the root cause:

 {F1978470518}

Adding the blaming enum name in the error message would have made my life much easier.

## Changelog:

[GENERAL][Added] - Improve error messages when enum members are missing

Reviewed By: rshest

Differential Revision: D75141414

fbshipit-source-id: 3625d817b218788891252add225f8fffb99e3145
This commit is contained in:
Yannick Loriot
2025-05-21 14:31:25 -07:00
committed by Facebook GitHub Bot
parent 5489e18abc
commit 12ced22f70
3 changed files with 32 additions and 32 deletions
@@ -434,7 +434,7 @@ function generateEnum(
)
.join(' else ') +
` else {
throw jsi::JSError(rt, "No appropriate enum member found for value");
throw jsi::JSError(rt, "No appropriate enum member found for value in ${enumName}");
}`;
const toCases =
@@ -446,7 +446,7 @@ function generateEnum(
)
.join(' else ') +
` else {
throw jsi::JSError(rt, "No appropriate enum member found for enum value");
throw jsi::JSError(rt, "No appropriate enum member found for enum value in ${enumName}");
}`;
return EnumTemplate({