Splunk MINT SDK for iOS

Splunk MINT SDK for iOS Developer Guide

Download manual as PDF

Download topic as PDF

Report handled exceptions

At times, you might expect your app to throws exceptions. When you handle those exceptions with a try-catch block, you can use the Splunk MINT exception handling feature to keep track of any exceptions your app throws and catches. Splunk MINT can also collect customized data associated with an exception. The Splunk MINT exception handling feature applies only to exceptions your application throws rather than to any app crashes that might occur. Use this to your advantage to create self-explanatory exceptions.

  • To log an exception with an extra key-value pair, use the logException:extraDataKey:extraDataValue: method.
  • To log an exception with an extra data list, use the logException:extraData: method.
  • To log an exception with no extra data, use the logException: method
  • As an alternative to the previous methods, you can use use the MintLogException(NSException, MintLimitedExtraData) macro to post an exception and its stacktrace along with optional extra data to identify it, as follows:
  • // Objective-C
    
      MintLimitedExtraData *limitedExtraData = [[MintLimitedExtraData alloc] init];
      [limitedExtraData setValue:@"value" forKey:@"key"];
      @try {
            NSArray* twoObjsArray = @[@"1", @"2"];
            NSString* objNotExist = [twoObjsArray objectAtIndex:3];
            NSLog(@"%@", [objNotExist description]);
        } @catch (NSException *exception) {
      
          MintLogException(exception, limitedExtraData);
          // or if you don't need to attach any extra data
          MintLogException(exception, nil);
       }
    

    The MintLogException macro is a shorthand of the logException:extraData: method, used as follows:

      
      @try {
            NSArray* twoObjsArray = @[@"1", @"2"];
            NSString* objNotExist = [twoObjsArray objectAtIndex:3];
            NSLog(@"%@", [objNotExist description]);
        }
        @catch (NSException *exception) {
            [[Mint sharedInstance] logException:exception extraDataKey:@"key" extraDataValue:@"value"];
            
            MintLimitedExtraData *limitedExtraData = [[MintLimitedExtraData alloc] init];
            [limitedExtraData setValue:@"value" forKey:@"key"];
            [[Mint sharedInstance] logException:exception extraData:limitedExtraData];
    
        }
    

    Using this method helps debug any problem.

To view handled exceptions, go to the Errors dashboard in Splunk MINT Management Console, and click Handled under Exception Type in the list of filters.

Note If you add handling for an exception that was previously displayed in MINT Management Console as a crash, this exception will continue to be displayed as a crash.
PREVIOUS
Dispatch system log messages
  NEXT
Add custom data to crash reports

This documentation applies to the following versions of Splunk MINT SDK for iOS: 5.2.x


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters