@@ -199,7 +199,7 @@ id convertJSIValueToObjCObject(
199199 return convertJSIObjectToNSDictionary (runtime, o, jsInvoker, useNSNull);
200200 }
201201
202- throw std::runtime_error ( " Unsupported jsi::Value kind" );
202+ throw jsi::JSError (runtime, " Unsupported jsi::Value kind" );
203203}
204204
205205static jsi::Value createJSRuntimeError (jsi::Runtime &runtime, const std::string &message)
@@ -268,14 +268,12 @@ id convertJSIValueToObjCObject(
268268 jsi::PropNameID::forAscii (runtime, " fn" ),
269269 2 ,
270270 [invokeCopy, jsInvoker = jsInvoker_, moduleName = name_, methodName](
271- jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
272- // FIXME: do not allocate this upfront
273- std::string moduleMethod = moduleName + " ." + methodName + " ()" ;
274-
271+ jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t count) mutable {
275272 if (count != 2 ) {
276- throw std::invalid_argument (
277- moduleMethod + " : Promise must pass constructor function two args. Passed " + std::to_string (count) +
278- " args." );
273+ throw jsi::JSError (
274+ rt,
275+ moduleName + " ." + methodName + " (): Promise must pass constructor function two args. Passed " +
276+ std::to_string (count) + " args." );
279277 }
280278 if (!invokeCopy) {
281279 return jsi::Value::undefined ();
@@ -306,12 +304,16 @@ id convertJSIValueToObjCObject(
306304 }
307305
308306 if (alreadyResolved) {
309- RCTLogError (@" %s : Tried to resolve a promise more than once." , moduleMethod.c_str ());
307+ RCTLogError (
308+ @" %s .%s (): Tried to resolve a promise more than once." , moduleName.c_str (), methodName.c_str ());
310309 return ;
311310 }
312311
313312 if (alreadyRejected) {
314- RCTLogError (@" %s : Tried to resolve a promise after it's already been rejected." , moduleMethod.c_str ());
313+ RCTLogError (
314+ @" %s .%s (): Tried to resolve a promise after it's already been rejected." ,
315+ moduleName.c_str (),
316+ methodName.c_str ());
315317 return ;
316318 }
317319
@@ -339,16 +341,18 @@ id convertJSIValueToObjCObject(
339341
340342 if (alreadyResolved) {
341343 RCTLogError (
342- @" %s : Tried to reject a promise after it's already been resolved. Message: %s " ,
343- moduleMethod.c_str (),
344+ @" %s .%s () Tried to reject a promise after it's already been resolved. Message: %s " ,
345+ moduleName.c_str (),
346+ methodName.c_str (),
344347 message.UTF8String );
345348 return ;
346349 }
347350
348351 if (alreadyRejected) {
349352 RCTLogError (
350- @" %s : Tried to reject a promise more than once. Message: %s " ,
351- moduleMethod.c_str (),
353+ @" %s .%s () Tried to reject a promise more than once. Message: %s " ,
354+ moduleName.c_str (),
355+ methodName.c_str (),
352356 message.UTF8String );
353357 return ;
354358 }
@@ -527,9 +531,9 @@ TraceSection s(
527531 break ;
528532 }
529533 case FunctionKind:
530- throw std::runtime_error ( " convertReturnIdToJSIValue: FunctionKind is not supported yet." );
534+ throw jsi::JSError (runtime, " convertReturnIdToJSIValue: FunctionKind is not supported yet." );
531535 case PromiseKind:
532- throw std::runtime_error ( " convertReturnIdToJSIValue: PromiseKind wasn't handled properly." );
536+ throw jsi::JSError (runtime, " convertReturnIdToJSIValue: PromiseKind wasn't handled properly." );
533537 }
534538
535539 return returnValue;
@@ -711,14 +715,13 @@ TraceSection s(
711715 NSMutableArray *retainedObjectsForInvocation)
712716{
713717 const char *moduleName = name_.c_str ();
714- const NSObject <RCTBridgeModule> *module = instance_;
715-
716718 if (isSync) {
717719 TurboModulePerfLogger::syncMethodCallArgConversionStart (moduleName, methodName);
718720 } else {
719721 TurboModulePerfLogger::asyncMethodCallArgConversionStart (moduleName, methodName);
720722 }
721723
724+ const NSObject <RCTBridgeModule> *module = instance_;
722725 NSMethodSignature *methodSignature = [module methodSignatureForSelector: selector];
723726 if (count > methodSignature.numberOfArguments - 2 ) {
724727 throw jsi::JSError (
@@ -751,7 +754,7 @@ TraceSection s(
751754 return true ;
752755 }
753756
754- return !( returnType == VoidKind || returnType == PromiseKind) ;
757+ return returnType != VoidKind && returnType != PromiseKind;
755758}
756759
757760ObjCTurboModule::ObjCTurboModule (const InitParams ¶ms)
0 commit comments