lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
246 stars 17 forks source link

25897711: Unable to catch NSException instances raised in a playground #14599

Open openradar-mirror opened 8 years ago

openradar-mirror commented 8 years ago

Description

Summary: Normally it is possible to execute Swift code wrapped in an Objective-C function which can catch any NSException instances that get raised. However when importing such a wrapper function into a playground and using it there, an exception causes playground execution to immediately halt, rather than the exception being caught.

Steps to Reproduce:

  1. Open the ExceptionCatcher Xcode workspace from the attached file, or cloned from: https://github.com/briancroom/RadarSamples
  2. Observe that the ExceptionCatcher.framework target exposes an Objective-C function which receives a block and executes it within an @try block, catching and logging any exceptions.
  3. Execute the unit tests for the framework, demonstrating the expected behavior where thrown exceptions are properly caught.
  4. Open and execute Playground.playground, which has the same client code as the unit tests

Expected Results: An exception thrown in a closure passed to the performBlockCatchingExceptions function should be caught and logged, and playground execution should continue

Actual Results: The exception causes playground execution to halt, and produces the following console output:

2016-04-24 16:20:13.697 Playground[10555:212120] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Boom' * First throw call stack: ( 0 CoreFoundation 0x000000010fdaed85 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010f820deb objc_exception_throw + 48 2 CoreFoundation 0x000000010fdae9c9 -[NSException raise] + 9 3 ExceptionCatcher 0x000000011affa8fe _TF16ExceptionCatcher16throwAnExceptionFTT + 174 4 ??? 0x000000011affe197 0x0 + 4747944343 5 ??? 0x000000011affe1de 0x0 + 4747944414 6 ExceptionCatcher 0x000000011affa7a1 performBlockCatchingExceptions + 49 7 ??? 0x000000011afe77e9 0x0 + 4747851753 8 Playground 0x000000010f2afab0 main + 0 9 Playground 0x000000010f2b29a1 _TTRXFodTXFo_iT__iT + 17 10 Playground 0x000000010f2b2401 _TPATTRXFodTXFo_iTiT + 81 11 Playground 0x000000010f2b29d0 _TTRXFo_iTiTXFodT + 32 12 Playground 0x000000010f2b2a07 _TTRXFodTXFdCbdT + 39 13 CoreFoundation 0x000000010fcd42ec CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12 14 CoreFoundation 0x000000010fcc9f75 CFRunLoopDoBlocks + 341 15 CoreFoundation 0x000000010fcc96d2 __CFRunLoopRun + 850 16 CoreFoundation 0x000000010fcc90f8 CFRunLoopRunSpecific + 488 17 GraphicsServices 0x00000001168d8ad2 GSEventRunModal + 161 18 UIKit 0x0000000110165f09 UIApplicationMain + 171 19 Playground 0x000000010f2aff39 main + 1161 20 libdyld.dylib 0x0000000112b0c92d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

Notes: This issue is preventing me from producing a playground that demonstrates the usage of an Objective-C framework

Product Version: Xcode 7.3 Created: 2016-04-27T19:32:45.663460 Originated: 2016-04-24T16:29:00 Open Radar Link: http://www.openradar.me/25897711

openradar-mirror commented 8 years ago

Modified: 2016-04-27T19:32:45.663750