• /
  • Log in
  • Free account

recordHandledException (iOS SDK API)

Syntax

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

Records a handled exception. Optionally takes map with additional attributes showing context.

Requirements

Agent version 5.15.0 or higher.

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 in the Crash event trail UI, and query them with NRQL.

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

Parameters

Parameter

Description

$exception

NSException

Required. The exception object that was thrown.

$attributes​

NSDictionary

Optional. Dictionary of attributes that give context.

Return values

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

Examples

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];
Create issueEdit page
Copyright © 2022 New Relic Inc.