From b79d7db9dbf588085b29274e507d34438e2e2595 Mon Sep 17 00:00:00 2001 From: Dmitry Dushkin Date: Tue, 7 May 2019 14:09:08 -0700 Subject: [PATCH] Consistent reporting native module name on crash on native side (#24741) Summary: _Reopened PR_ https://github.com/facebook/react-native/pull/24704#issuecomment-490017599 PR https://github.com/facebook/react-native/pull/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: https://github.com/facebook/react-native/pull/24741 Differential Revision: D15242415 Pulled By: cpojer fbshipit-source-id: 8346ffd7c74070ec676aa006c9791a4729946204 --- ReactCommon/jsi/JSCRuntime.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index eea02793439dca..2b5341c3f9a02b 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -664,11 +664,11 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr ho) { static JSValueRef getProperty( JSContextRef ctx, JSObjectRef object, - JSStringRef propertyName, + JSStringRef propName, JSValueRef* exception) { auto proxy = static_cast(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); @@ -681,14 +681,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr 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("): ")); *exception = rt.valueRef(excValue); return JSValueMakeUndefined(ctx); } @@ -718,14 +724,20 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr 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: "); + .call( + rt, + std::string("Exception in HostObject::set(propName:") + + JSStringToSTLString(propName) + + std::string("): ")); *exception = rt.valueRef(excValue); return false; }