Files
swift-mirror/test/Concurrency/Runtime/Inputs/ObjCExceptionHelpers.h
Mike Ash 058b1ed822 [Concurrency] Block exception propagation through swift_job_run.
When an exception is thrown through swift_job_run, it leaves the Concurrency runtime in an inconsistent state, which can lead to misbehavior or crashes later on. It's very difficult to work out what the cause is when this happens. Since the program state is doomed once this happens, prevent exceptions from propagating through swift_job_run at all, and terminate immediately when throwing.

rdar://171909991
2026-05-08 10:16:29 -04:00

17 lines
389 B
Objective-C

#import <Foundation/Foundation.h>
static inline id _Nullable CatchingException(void (^_Nonnull block)(void)) {
@try {
block();
} @catch (id e) {
return e;
}
return nil;
}
static inline void ThrowObjCException(void) {
@throw [NSException exceptionWithName:@"test"
reason:@"I feel like it"
userInfo:nil];
}