Re: Exception going "uncaught" despite active @catch handler
Re: Exception going "uncaught" despite active @catch handler
- Subject: Re: Exception going "uncaught" despite active @catch handler
- From: Jens Alfke <email@hidden>
- Date: Fri, 11 Apr 2014 15:18:01 -0700
On Apr 11, 2014, at 2:26 PM, Greg Parker <email@hidden> wrote:
> libdispatch has its own catch-and-halt exception handler here. It does not allow exceptions to be thrown across its boundaries. The GCD reference says "Your application must catch all exceptions before returning from a block submitted to a dispatch queue."
Makes sense, since that boundary is the moral equivalent of a different thread. I’m more used to using perform-after-delay to schedule calls, and CFRunLoop is more forgiving about exceptions, so this didn’t occur to me till after I’d posted.
> You may be able to use std::set_terminate() to install a handler that records the test progress so your test machinery can start a new test process where it left off.
The method that does the dispatch_async calls is in a pretty central place in my code, so I put an @catch block in it to consume the exception before it gets back to GCD. The @catch block also has a hook to my test framework to notify it that the exception occurred, so even though RunTest never sees the exception itself, it knows the test has failed and reports it as such.
—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