Skip to content

Instantly share code, notes, and snippets.

@emarashliev
Last active July 5, 2017 18:44
Show Gist options
  • Save emarashliev/900ab39490c672b04ea781e0abd18d1e to your computer and use it in GitHub Desktop.
Save emarashliev/900ab39490c672b04ea781e0abd18d1e to your computer and use it in GitHub Desktop.
Catch NSException in Swift
@implementation TryCatch
+ (void)try:(void(^_Nonnull)())try
catch:(nullable void(^)(NSException* _Nullable exception))catch
finally:(nullable void(^)())finally {
@try {
try ? try() : nil;
}
@catch (NSException *exception) {
catch ? catch(exception) : nil;
}
@finally {
finally ? finally() : nil;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment