TurboModules: Improve Error Message

Summary: More verbose but descriptive error message when `TurboModule.getEnforcing` fails to find a native module.

Reviewed By: cpojer, gaearon

Differential Revision: D15619293

fbshipit-source-id: 0e8af4986d6ce9002966bb062766218ce9f89a13
This commit is contained in:
Tim Yung
2019-06-05 17:35:01 -07:00
committed by Facebook Github Bot
parent d45818fe47
commit 8a014cdfb3
+5 -1
View File
@@ -33,6 +33,10 @@ export function get<T: TurboModule>(name: string): ?T {
export function getEnforcing<T: TurboModule>(name: string): T {
const module = get(name);
invariant(module != null, `${name} is not available in this app.`);
invariant(
module != null,
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
'Verify that a module by this name is registered in the native binary.',
);
return module;
}