Skip to content

Commit

Permalink
Consistent reporting native module name on crash on native side (#24741)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Dmitry Dushkin authored and facebook-github-bot committed May 7, 2019
1 parent ff9f8f3 commit b79d7db
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions ReactCommon/jsi/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,11 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
static JSValueRef getProperty(
JSContextRef ctx,
JSObjectRef object,
JSStringRef propertyName,
JSStringRef propName,
JSValueRef* exception) {
auto proxy = static_cast<HostObjectProxy*>(JSObjectGetPrivate(object));
auto& rt = proxy->runtime;
jsi::PropNameID sym = rt.createPropNameID(propertyName);
jsi::PropNameID sym = rt.createPropNameID(propName);
jsi::Value ret;
try {
ret = proxy->hostObject->get(rt, sym);
Expand All @@ -681,14 +681,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
.getPropertyAsFunction(rt, "Error")
.call(
rt,
std::string("Exception in HostObject::get: ") + ex.what());
std::string("Exception in HostObject::get(propName:")
+ JSStringToSTLString(propName)
+ std::string("): ") + ex.what());
*exception = rt.valueRef(excValue);
return JSValueMakeUndefined(ctx);
} catch (...) {
auto excValue =
rt.global()
.getPropertyAsFunction(rt, "Error")
.call(rt, std::string("Exception in HostObject::get: ") + JSStringToSTLString(propertyName));
.call(
rt,
std::string("Exception in HostObject::get(propName:")
+ JSStringToSTLString(propName)
+ std::string("): <unknown>"));
*exception = rt.valueRef(excValue);
return JSValueMakeUndefined(ctx);
}
Expand Down Expand Up @@ -718,14 +724,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
.getPropertyAsFunction(rt, "Error")
.call(
rt,
std::string("Exception in HostObject::set: ") + ex.what());
std::string("Exception in HostObject::set(propName:")
+ JSStringToSTLString(propName)
+ std::string("): ") + ex.what());
*exception = rt.valueRef(excValue);
return false;
} catch (...) {
auto excValue =
rt.global()
.getPropertyAsFunction(rt, "Error")
.call(rt, "Exception in HostObject::set: <unknown>");
.call(
rt,
std::string("Exception in HostObject::set(propName:")
+ JSStringToSTLString(propName)
+ std::string("): <unknown>"));
*exception = rt.valueRef(excValue);
return false;
}
Expand Down

0 comments on commit b79d7db

Please sign in to comment.