mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
fix(companion): type on the main thread and recover from focus assertions
This commit is contained in:
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
|
||||
Reference in new issue
Block a user