Re: exception in init
Re: exception in init
- Subject: Re: exception in init
- From: Jens Alfke <email@hidden>
- Date: Wed, 04 Apr 2012 09:55:48 -0700
On Apr 4, 2012, at 9:29 AM, Andreas Grosam wrote:
> The problem on Mac OS X in Cocoa Apps is, that there is no alert. The application also does not stop, or terminate gracefully. The default behavior of the event loop is to log an error message, and then **continue**.
Not anymore. In Lion you get a very nice "Internal error / An uncaught exception was raised..." alert, with buttons "Show Details", "Crash", "Continue".
I think it's important to give the user the option to continue, even if the app may be unstable. The user might have some critical unsaved data (assuming this isn't an app that autosaves.)
> Note, this is the default behavior. If you want to handle exceptions and possibly terminate the app, AFAIK it requires a very elaborated procedure, unless someone proves me wrong, and shows a simple code snippet how to terminate gracefully after encountering an exception.
https://github.com/snej/MYUtilities/blob/master/ExceptionUtils.h
Make your app's main class be MYExceptionReportingApp instead of NSApplication, and exceptions will be reported with an alert. I haven't tested this functionality recently so I don't know if it still works in Lion, and anyway you might want to add code to no-op it in that case so the nice Apple alert shows up instead.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden