Feature Idea: Handled Crashes/Exceptions iOS

I’m trying to find a way of register NSException(s) as crashes.

I use the following to get the crash handler and register the exception

NSException *ex = [NSException exceptionWithName:@"exceptionWithName" reason:@"reason" userInfo:@{}];
NSUncaughtExceptionHandler *crashHandler = NSGetUncaughtExceptionHandler();

But I’m getting the following stack trace with error

__pthread_kill + 8
pthread_kill + 112
abort + 140
-[NRPLCrashReporter generateLiveReportWithThread:] (PLCrashReporter.m:656)

Does anyone know how to register a handled exception the same way a crash does?

I want to be able to see the exact same information I’d see in a crash report.

I’m conducting a research looking for crash reporting tool for my company and so far New Relic looks great but lacks of this feature. I’ve looked into New Relic, Crashlytics and Crittercism and the only one providing this so far is Crittercism.

Please, responde ASAP so I can conclude this task.

New Relic edit

A way to gather the interactions for the session - Vote Here

  • I want this, too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.

It seems there may be a bit of confusion on the different aspects of crashes: Exceptions (Caught and Uncaught), and the Exception Handler as it relates to iOS crash reporting.

Assuming New Relic is the only Crash Handler (iOS only allows one), the agent will handle uncaught crashes(NSExceptions like in your example that are not in a try/catch block) and store the exception information (Stack trace, App metadata, interaction trail) and report that back to New Relic the next time the app is launched. The application will still crash, but the critical information about the crash circumstances will be reported so you can debug it later.

In your example, you’ve defined an exception, but not raised it, registered an uncaught crash handler (remember there can be only one!) and then passed the exception to the handler. This causes a crash in the app, but since there are two uncaught exception handlers, it’s unclear which will take ownership of the exception (generally it’s the handler which was registered last, but this is not always the case).

New Relic provides a simple API mechanism to test crash reporting, but you will need to make sure the Xcode debugger is disabled - the debugger trumps all exception handlers from any 3rd party. Here’s what that would look like:

    [NewRelic crashNow:@"This is an example exception provided by the New Relic iOS agent"];

Just make sure to call this after starting the agent.

Hopefully that clears things up a bit, but if you still have questions just ask!

Thanks for the response @pknudsen!

The main point here is that I don’t want the app to crash, but I want to track as it would.

I think New Relic is a great product but it lacks from this feature. I found that Crashlytics as well offers it:

I hope you add it soon so I can use only New Relic. By the time being I’m only going to use it for monitoring the network and Crashlytics for exceptions (unhandled or handled).


Tracking non-fatal exceptions (logical try/catch blocks) is something that can be done with the New Relic Mobile SDKs via the custom event APIs: Android, iOS. With both of these API’s custom events can be created that include any attributes you see fit - exception types, messages, frames, metadata. These events can then be queried for further analysis, or dashboards made to gauge their usage.

Something else to keep in mind: the SO article you linked, it is noted that: This API is not intended be to used to log NSException objects. when referring to the recordCustomExceptionName API. NSExceptions shouldn’t be considered non-fatal.

@pknudsen I like the idea of using custom events to track handled errors but I can’t figure out a way to get a list of the latests interactions so I can attach it to my custom handled error. This would be helpful the same way it is helpful in the crash list.

That would be a pretty nifty API - a way to gather the interactions for the session. I’ll get a feature request added so it can be review by product management. Thanks for the feedback!

Any news on this feature? We are evaluating New Relic for our Android app, but the lack of Caught Exceptions reporting is big hole in a feature set which is otherwise excellent.
The implementation for you should be quite simple as you could reuse most of the Crash reporting pipeline/UI.
The Ruby agent already supports this https://docs.newrelic.com/docs/agents/ruby-agent/troubleshooting/sending-new-relic-handled-errors

No news right now, @quido! I’ll be sure to pass your insight and needs along to our Mobile Product Manager. Please also participate in our new Feature Idea process by casting your vote in the poll above. :blush:

@elmaildejuan @fcy @quido Thanks so much for your requests! We have released support for Handled Exceptions on iOS and Android. Please check it out and reach out with your feedback. https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-ui/crashes/introduction-mobile-handled-exceptions
All the best, Susie

1 Like