• /
  • ログイン
  • 無料アカウント

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 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 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];

その他のヘルプ

さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:

問題を作成するこのページを編集する
Copyright © 2020 New Relic Inc.