• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: catching uncaught exceptions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: catching uncaught exceptions


  • Subject: Re: catching uncaught exceptions
  • From: cricket <email@hidden>
  • Date: Mon, 9 Feb 2004 23:03:00 -0800

I recommend looking at the NSExceptionHandler class. I have tested this in one of my projects and it works well. Although I'm not sure this is the best way to use it, I ended up setting it up in the init method for my main controller class, like this:

NSExceptionHandler *handler = [NSExceptionHandler defaultExceptionHandler];
[handler setExceptionHandlingMask:NSLogAndHandleEveryExceptionMask];
[handle setDelegate:self];

Then, implemented one of the delegate methods:

- (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldHandleException:(NSE
xception *)exception mask:(unsigned int)aMask {
-- Put up your alert if need be
-- Then, decide on what to do, perhaps based on aMask
}

- cricket

On Feb 9, 2004, at 8:10 PM, matt neuburg wrote:

I want to override Cocoa's policy of failing silently
with a note to the Console when there is an exception,
so I have created an NSApplication subclass and
implemented reportException: to call NSRunAlertPanel and
tell the user.

But it isn't working. When I deliberately generate an
out-of-bounds range error in my code, it winds up in the
Console log and there is no alert panel:


Why not use NSSetUncaughtExceptionHandler(), and use it to call
NSApplication's reportException:?

I haven't tested this

Do test it, then, and see if you can get it to work in the circumstances
described. m.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: catching uncaught exceptions
      • From: matt neuburg <email@hidden>
  • Prev by Date: Re: Making the correct button the default button?
  • Next by Date: Re: NSTableView fontsize
  • Previous by thread: Re: catching uncaught exceptions
  • Next by thread: Re: catching uncaught exceptions
  • Index(es):
    • Date
    • Thread