Splunk MINT SDK for iOS (Legacy)

Splunk MINT SDK for iOS Developer Guide

Acrobat logo Download manual as PDF


Splunk MINT is no longer available for purchase as of January 29, 2021. Customers who have already been paying to ingest and process MINT data in Splunk Enterprise will continue to receive support until December 31, 2021, which is End of Life for all MINT products: App, Web Service (Management Console), SDK and Add-On.
This documentation does not apply to the most recent version of Splunk MINT SDK for iOS (Legacy). For documentation on the most recent version, go to the latest release.
Acrobat logo 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 logExceptionAsync:extraDataKey:extraDataValue: method.
  • To log an exception with an extra data list, use the logExceptionAsync:limitedExtraDataList: method.
  • To log an exception with no extra data, use the logExceptionAsync:limitedExtraDataList: method, but pass nil in the limitedExtraData: parameter.
  • As an alternative to the previous methods, you can use use the MintLogException(NSException, LimitedExtraDataList) macro to post an exception and its stacktrace along with optional extra data to identify it, as follows:
  • // Objective-C
    
    LimitedExtraDataList* limitedExtraData = [LimitedExtraDataList new];
    [limitedExtraData add:[[ExtraData alloc] initWithKey:@"TestKey1" andValue:@"TestValue1"]];
    @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 logExceptionAsync:limitedExtraDataList:completionBlock: method, used as follows:

    LimitedExtraDataList* limitedExtraData = [LimitedExtraDataList new];
    [limitedExtraData add:[[ExtraData alloc] initWithKey:@"TestKey1" andValue:@"TestValue1"]];
    @try
    {
        NSArray* twoObjsArray = @[@"1", @"2"];
        NSString* objNotExist = [twoObjsArray objectAtIndex:3];
        NSLog(@"%@", [objNotExist description]);
    }
    @catch (NSException *exception)
    {
        [[Mint sharedInstance] logExceptionAsync:exception limitedExtraDataList:limitedExtraData completionBlock:^(MintLogResult *mintLogResult)
        {
            NSString* message = [NSString stringWithFormat:@"Log result: %@", mintLogResult.resultState == 0 ? @"OK" : @"Error"];
            NSLog(@"%@", message);
            NSLog(@"Log exception JSON request: %@", mintLogResult.clientRequest);
        }];
    }
    

    Using this method helps debug any problem. To get information about the request in general, add a block implementation and examine the MintLogResult object. You can safely pass nil for a completion block.

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.
Last modified on 28 August, 2015
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 (Legacy): 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x


Was this documentation topic helpful?


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