Skip to content

Commit

Permalink
Stop throwing exceptions from the CallbackBridge constructor on Darwi…
Browse files Browse the repository at this point in the history
…n. (#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.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 11, 2023
1 parent a19b020 commit 73010d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/darwin/Framework/CHIP/CHIPCallbackBridgeBase_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ template <class T> 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]);
}
};

Expand Down

0 comments on commit 73010d8

Please sign in to comment.