Skip to content

Commit b79d7db

Browse files
Dmitry Dushkinfacebook-github-bot
Dmitry Dushkin
authored andcommitted
Consistent reporting native module name on crash on native side (#24741)
Summary: _Reopened PR_ #24704 (comment) PR #24633 introduced some inconsistency in crash messaging, this PR fix it. Asked by mhorowitz [General] [Added] - Consistent reporting native module name on crash on native side Pull Request resolved: #24741 Differential Revision: D15242415 Pulled By: cpojer fbshipit-source-id: 8346ffd7c74070ec676aa006c9791a4729946204
1 parent ff9f8f3 commit b79d7db

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

ReactCommon/jsi/JSCRuntime.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,11 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
664664
static JSValueRef getProperty(
665665
JSContextRef ctx,
666666
JSObjectRef object,
667-
JSStringRef propertyName,
667+
JSStringRef propName,
668668
JSValueRef* exception) {
669669
auto proxy = static_cast<HostObjectProxy*>(JSObjectGetPrivate(object));
670670
auto& rt = proxy->runtime;
671-
jsi::PropNameID sym = rt.createPropNameID(propertyName);
671+
jsi::PropNameID sym = rt.createPropNameID(propName);
672672
jsi::Value ret;
673673
try {
674674
ret = proxy->hostObject->get(rt, sym);
@@ -681,14 +681,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
681681
.getPropertyAsFunction(rt, "Error")
682682
.call(
683683
rt,
684-
std::string("Exception in HostObject::get: ") + ex.what());
684+
std::string("Exception in HostObject::get(propName:")
685+
+ JSStringToSTLString(propName)
686+
+ std::string("): ") + ex.what());
685687
*exception = rt.valueRef(excValue);
686688
return JSValueMakeUndefined(ctx);
687689
} catch (...) {
688690
auto excValue =
689691
rt.global()
690692
.getPropertyAsFunction(rt, "Error")
691-
.call(rt, std::string("Exception in HostObject::get: ") + JSStringToSTLString(propertyName));
693+
.call(
694+
rt,
695+
std::string("Exception in HostObject::get(propName:")
696+
+ JSStringToSTLString(propName)
697+
+ std::string("): <unknown>"));
692698
*exception = rt.valueRef(excValue);
693699
return JSValueMakeUndefined(ctx);
694700
}
@@ -718,14 +724,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
718724
.getPropertyAsFunction(rt, "Error")
719725
.call(
720726
rt,
721-
std::string("Exception in HostObject::set: ") + ex.what());
727+
std::string("Exception in HostObject::set(propName:")
728+
+ JSStringToSTLString(propName)
729+
+ std::string("): ") + ex.what());
722730
*exception = rt.valueRef(excValue);
723731
return false;
724732
} catch (...) {
725733
auto excValue =
726734
rt.global()
727735
.getPropertyAsFunction(rt, "Error")
728-
.call(rt, "Exception in HostObject::set: <unknown>");
736+
.call(
737+
rt,
738+
std::string("Exception in HostObject::set(propName:")
739+
+ JSStringToSTLString(propName)
740+
+ std::string("): <unknown>"));
729741
*exception = rt.valueRef(excValue);
730742
return false;
731743
}

0 commit comments

Comments
 (0)