fix(companion): type on the main thread and recover from focus assertions

This commit is contained in:
pj committed 2026-06-07 15:59:15 +05:30
1 parent 76cbf1a102
commit fc215695a2
2 files changed
+55 -18

No files matched your search

@@ -35,4 +35,20 @@ NS_ASSUME_NONNULL_BEGIN
completion:(void (^)(NSError *_Nullable error))completion;
@end
// Runs the block and converts any raised NSException into an NSError so a
// testing-framework assertion does not terminate the runner process.
NS_INLINE BOOL CompanionRunCatching(void (^block)(void), NSError *_Nullable *_Nullable error) {
@try {
block();
return YES;
} @catch (NSException *exception) {
if (error) {
*error = [NSError errorWithDomain:@"dev.sanderling.companion"
code:1
userInfo:@{NSLocalizedDescriptionKey: exception.reason ?: exception.name}];
}
return NO;
}
}
NS_ASSUME_NONNULL_END