8

I'm trying to make a general error handler for an iPhone app that brings the user to a recovery screen whenever any general error is thrown in the application without putting a try/catch block around every single method in the application.

Using NSSetUncaughtExceptionHandler doesn't work because the application terminates after the handler is run.

Is there any way to change this behavior, or use any other handler that will catch exceptions in general and not cause the application to exit afterward?

And please, no non-answers about whether it's a good or bad idea.

asked Jan 20, 2010 at 17:40

Ed Marty's user avatar

1

11

The original poster has probably solved his problem by now. However, for anyone who comes across this in the future...

Matt Gallagher wrote an excellent post on catching unhandled exceptions and signals a few months after this question was posted. I find it to be much more informative than the answer referenced above by Scott.

In particular, Matt's post describes how to attempt a recovery (if appropriate) that allows your app to keep running, and even displays a UIAlertView with error information if you want (hint: it involves creating a new run loop).

Community's user avatar

answered Jul 20, 2010 at 18:05

clint's user avatar

Comments

2

This was answered here. You can read more about the responder chain and catching the exceptions here. The write up from 1 is really good and explains how to deal with what you are doing.

Community's user avatar

answered Jan 20, 2010 at 21:50

Scott Densmore's user avatar

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.