> On May 28, 2021, at 8:41 PM, James Walker <jam...@frameforge.com> wrote:
> 
> On 5/28/21 4:21 PM, Matt Jacobson wrote:
>> On May 28, 2021, at 6:54 PM, James Walker via Cocoa-dev 
>> <cocoa-dev@lists.apple.com> wrote:
>>> When an uncaught exception is raised, I want to log some information about 
>>> it but let it continue on as normal.  But when I use NSExceptionHandler, an 
>>> uncaught exception displays an "Internal Error" modal dialog with buttons 
>>> "Show Details", "Crash", and "Continue".  I don't see any explicit mention 
>>> of this dialog in the API docs for NSExceptionHandler or in the "Exception 
>>> Programming Topics" guide.  I suppose that is what is meant when the 
>>> documentation of the method setExceptionHangingMask: talks about cases that 
>>> will "halt execution for debugging".  But I set this mask to 0, so I would 
>>> think it would never show the dialog, yet it does.  I have an 
>>> NSExceptionHandlerDelegate whose delegate methods always return NO, meaning 
>>> do not handle or log the exception.  Is there any way to just watch 
>>> exceptions go by without showing this dialog?
>> Without commenting on the wisdom of blowing past exceptions 😉, I’ll note 
>> that:
>> 
>> 1. NSExceptionHandler doesn’t allow you to prevent uncaught exceptions 
>> (whether truly uncaught or caught by one of AppKit’s last-resort catches) 
>> from being reported to +reportException:.  It in fact goes out of its way to 
>> make sure it does not impede this
>> 
>> 2. Buuuut… the default behavior in Cocoa of an uncaught exception is to 
>> ignore it.  You’re seeing this dialog because you have the user default 
>> `NSApplicationShowExceptions` set somewhere.  (Use `defaults find` to help 
>> find out where.)  It’s not on by default, but you may have turned it on at 
>> some point because of the aforementioned wisdom
>> 
> Thank you very much.  NSApplicationShowExceptions was indeed turned on in the 
> global domain; I probably did that years ago and forgot about it.  And I 
> didn't know about Cocoa defaulting to ignoring uncaught exceptions, I thought 
> it would kill the app like uncaught C++ exceptions do.  So I wasn't expecting 
> to "blow past" exceptions, I was expecting to crash.

Then you might be interested in another user default: 
`NSApplicationCrashOnExceptions`.  Basically, it pretends you always click the 
“Crash” button in that dialog.

Again, not on by default, so don’t rely on it!

Matt
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to