From 73010d8220b6fc31d483843f86fa36c6060bc475 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 16 Dec 2021 20:52:13 -0500 Subject: [PATCH] Stop throwing exceptions from the CallbackBridge constructor on Darwin. (#13094) This leads to a weird situation where depending on exactly what the action block does we might throw from the call _and_ queue up an async error report, or maybe we'll just do an async error report. Instead, just reuse our normal async error report machinery to report the error we ran into. --- .../Framework/CHIP/CHIPCallbackBridgeBase_internal.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h b/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h index 35a97dc7bffb17..cef8ff70cbf955 100644 --- a/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h +++ b/src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h @@ -41,12 +41,12 @@ template class CHIPCallbackBridge { }); if (CHIP_NO_ERROR != err) { - dispatch_async(queue, ^{ - handler(nil, [CHIPError errorForCHIPErrorCode:err]); - }); + NSLog(@"Failure performing action. C++-mangled success callback type: '%s', error: %s", typeid(T).name(), + chip::ErrorStr(err)); - NSString * errorStr = [NSString stringWithFormat:@"%s: %s", typeid(T).name(), chip::ErrorStr(err)]; - @throw [NSException exceptionWithName:errorStr reason:nil userInfo:nil]; + // Take the normal async error-reporting codepath. This will also + // handle cleaning us up properly. + DispatchFailure(this, [CHIPError errorForCHIPErrorCode:err]); } };