Skip to content

Instantly share code, notes, and snippets.

@siberianisaev
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siberianisaev/7de64c5cb57d5a3997ae to your computer and use it in GitHub Desktop.
Save siberianisaev/7de64c5cb57d5a3997ae to your computer and use it in GitHub Desktop.
Exception Handler
#import <Foundation/Foundation.h>
@interface ExceptionHandler : NSObject
+ (void)startHandleExceptions;
@end
#import "ExceptionHandler.h"
@implementation ExceptionHandler
+ (ExceptionHandler *)handler
{
static ExceptionHandler *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[ExceptionHandler alloc] init];
});
return sharedInstance;
}
/**
Call this method in App Delegate -application:didFinishLaunchingWithOptions:
*/
+ (void)startHandleExceptions
{
[[ExceptionHandler handler] setExceptionHandler];
}
static void uncaughtExceptionHandler(NSException *exception){
NSLog(@"Crash: %@", exception);
NSLog(@"Stack trace: %@", [exception callStackSymbols]);
//[Flurry logError:@"Uncaught exception handled." message:@"App crash registered!" exception:exception];
}
- (void)setExceptionHandler
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment