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 |
---|---|
NSException | Required. The exception object that was thrown. |
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];
For more help
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.