init iOS module
This commit is contained in:
35
iOS/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m
generated
Normal file
35
iOS/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m
generated
Normal file
@@ -0,0 +1,35 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user