recordHandledException

recordHandledException:(NSException* __nonnull)exception withAttributes:(NSDictionary* __nullable)attributes;
Records a handled exception. Optionally takes map with additional attributes showing context.

Requirements

Description

The recordHandledException API is useful for crash analysis; the captured events will help you understand how often your application is throwing exceptions and under what conditions. In addition to associated custom attributes, the events will also have associated session attributes.

This API takes an instance of an NSException and an optional NSDictionary attribute dictionary, then creates a recordHandledException event. You can view event data both in Insights and in New Relic Mobile's UI, in the Crash event trail.

For context on how to use this API, see the documentation about sending custom attributes and events to Insights for:

Parameters

Parameter Description

$exception

NSException

Required. The exception object that was thrown.

$attributes​

NSDictionary

Optional. Dictionary of attributes that give context.

Return value(s)

Returns true if the handled exception was recorded successfully, or false if not.

Example(s)

Objective-C

Method:

+ (BOOL) recordHandledException:(NSException* __nonnull)exception withAttributes:(NSDictionary* __nullable)attributes;

+ (BOOL) recordHandledException:(NSException* __nonnull)exception;

Examples:

Simple Objective-C example:

@try {
       @throw [NSException exceptionWithName:@"versionException"
                                      reason:@"App version no longer supported"
                                    userInfo:nil];
     } @catch (NSException* e) {
       [NewRelic recordHandledException:e];
     }

Objective-C example with dictionary:

NSException *exception = [NSException exceptionWithName:@"MyException" reason:@"I have my reason" userInfo:nil];
    
    NSDictionary* dictionary = @{@"int": @1,
                                 @"Test Group" : @"A | B"};
    
    [NewRelic recordHandledException:exception withAttributes:dictionary];

For more help

Recommendations for learning more: