Files
Sourcery/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m
T
Maximilian Landsmann 192aa719f4 Xcode 10 & Swift 4.2 (#683)
* FIX build with Xcode 10 (GM)

* updated pods to support swift 4.2

* fixed 2 now (sometimes) failing tests

* updated readme

* update circle-ci to use xcode 10

* updated swift package manager versions

* ensure consistent order in allVariables

* fix failing tests

* use latest cocoapods beta, pod install

* pod update, swift package update
2018-09-23 02:11:00 +03:00

36 lines
851 B
Objective-C

#import "NMBExceptionCapture.h"
@interface NMBExceptionCapture ()
@property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable);
@property (nonatomic, copy) void(^ _Nullable finally)(void);
@end
@implementation NMBExceptionCapture
- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally {
self = [super init];
if (self) {
self.handler = handler;
self.finally = finally;
}
return self;
}
- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock {
@try {
unsafeBlock();
}
@catch (NSException *exception) {
if (self.handler) {
self.handler(exception);
}
}
@finally {
if (self.finally) {
self.finally();
}
}
}
@end