@@ -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 }
@@ -539,9 +543,9 @@ TraceSection s(
539543 break ;
540544 }
541545 case FunctionKind:
542- throw std::runtime_error ( " convertReturnIdToJSIValue: FunctionKind is not supported yet." );
546+ throw jsi::JSError (runtime, " convertReturnIdToJSIValue: FunctionKind is not supported yet." );
543547 case PromiseKind:
544- throw std::runtime_error ( " convertReturnIdToJSIValue: PromiseKind wasn't handled properly." );
548+ throw jsi::JSError (runtime, " convertReturnIdToJSIValue: PromiseKind wasn't handled properly." );
545549 }
546550
547551 return returnValue;
@@ -723,14 +727,13 @@ TraceSection s(
723727 NSMutableArray *retainedObjectsForInvocation)
724728{
725729 const char *moduleName = name_.c_str ();
726- const NSObject <RCTBridgeModule> *module = instance_;
727-
728730 if (isSync) {
729731 TurboModulePerfLogger::syncMethodCallArgConversionStart (moduleName, methodName);
730732 } else {
731733 TurboModulePerfLogger::asyncMethodCallArgConversionStart (moduleName, methodName);
732734 }
733735
736+ const NSObject <RCTBridgeModule> *module = instance_;
734737 NSMethodSignature *methodSignature = [module methodSignatureForSelector: selector];
735738 if (count > methodSignature.numberOfArguments - 2 ) {
736739 throw jsi::JSError (
@@ -767,7 +770,7 @@ TraceSection s(
767770 return true ;
768771 }
769772
770- return !( returnType == VoidKind || returnType == PromiseKind) ;
773+ return returnType != VoidKind && returnType != PromiseKind;
771774}
772775
773776ObjCTurboModule::ObjCTurboModule (const InitParams ¶ms)
0 commit comments