Exception going "uncaught" despite active @catch handler
Exception going "uncaught" despite active @catch handler
- Subject: Exception going "uncaught" despite active @catch handler
- From: Jens Alfke <email@hidden>
- Date: Fri, 11 Apr 2014 14:12:58 -0700
I’ve got a weird situation where an NSAssertion failure is terminating the process with an “uncaught exception” even though there’s an @try block at a lower stack frame ready to catch it. Stack is below. The RunTestCase() function, down at frame 20, is calling the unit-test function inside of a block like @try{ … } @catch(NSException *x) { … } but the catch block is never entered. Instead the process just quits.
This is screwing up our automated testing, because unit tests after this failing one are never run. Normally the RunTestCase function just logs the exception and marks the test as failed, then continues to the next one. [Note: this is a custom unit test framework, entirely unrelated to OCUnit.]
After a bit more debugging I’ve caught the _dispatch_client_callout function at frame 12 calling objc_terminate after the assertion fails. I suppose it has its own catch block that responds by killing the process. Is there any way around this? I know the Obj-C religion is that exceptions “normally shouldn’t be caught”, but this isn’t exactly a normal situation, it’s unit testing.
—Jens
2014-04-11 13:58:06.550 Couchbase Lite Demo[61665:303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Assertion failed: BOGUS'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8c48f25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8e74ae75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c48f038 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff8805ce06 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
4 CouchbaseLite 0x000000010017bdcc _AssertFailed + 764
5 CouchbaseLite 0x000000010016adbf -[CBL_ReplicationObserverHelper replChanged:] + 95
6 CoreFoundation 0x00007fff8c45de0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
7 CoreFoundation 0x00007fff8c3518dd _CFXNotificationPost + 2893
8 Foundation 0x00007fff87f677ba -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
9 CouchbaseLite 0x00000001001365e7 -[CBLReplication updateStatus:error:processed:ofTotal:] + 887
10 CouchbaseLite 0x00000001001374a5 __35-[CBLReplication bg_updateProgress]_block_invoke + 53
11 libdispatch.dylib 0x00007fff8c7151bb _dispatch_call_block_and_release + 12
12 libdispatch.dylib 0x00007fff8c71228d _dispatch_client_callout + 8
13 libdispatch.dylib 0x00007fff8c719ef0 _dispatch_main_queue_callback_4CF + 333
14 CoreFoundation 0x00007fff8c3f65a9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
15 CoreFoundation 0x00007fff8c3b17c4 __CFRunLoopRun + 1636
16 CoreFoundation 0x00007fff8c3b0f25 CFRunLoopRunSpecific + 309
17 Foundation 0x00007fff87fcdadc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 253
18 Foundation 0x00007fff8801610b -[NSRunLoop(NSRunLoop) runUntilDate:] + 78
19 Couchbase Lite Demo 0x000000010001b0ba Test_CBLIncrementalStoreCBLIntegration + 4522
20 CouchbaseLite 0x000000010017a38f RunTestCase + 223
21 CouchbaseLite 0x000000010017ab9e RunTestCases + 318
22 Couchbase Lite Demo 0x0000000100001392 main + 34
23 libdyld.dylib 0x00007fff85a015fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
_______________________________________________
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