diff --git a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp index 7a35097bf..b699fb90f 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridFunction.hpp @@ -173,7 +173,14 @@ class HybridFunction final { // 1. Convert jsi::Value to jsi::Object #ifdef NITRO_DEBUG if (!value.isObject()) [[unlikely]] { - throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + " - `this` is not bound!"); + throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + + " - `this` is not bound! Suggestions:\n" + "- Did you accidentally destructure the `HybridObject`? (`const { " + + funcName + + " } = ...`)\n" + "- Did you call `dispose()` on the `HybridObject` before?" + "- Did you accidentally call `" + + funcName + "` on the prototype directly?"); } #endif jsi::Object object = value.getObject(runtime); @@ -183,10 +190,12 @@ class HybridFunction final { if (!object.hasNativeState(runtime)) [[unlikely]] { throw jsi::JSError(runtime, "Cannot " + getHybridFuncDebugInfo(funcKind, funcName) + " - `this` does not have a NativeState! Suggestions:\n" - "- Did you accidentally destructure the `HybridObject` and lose a reference to the original object?\n" + "- Did you accidentally destructure the `HybridObject`? (`const { " + + funcName + + " } = ...`)\n" "- Did you call `dispose()` on the `HybridObject` before?" "- Did you accidentally call `" + - funcName + "` on the prototype directly?\n"); + funcName + "` on the prototype directly?"); } #endif