jmpeek454 / google-toolbox-for-mac

Automatically exported from code.google.com/p/google-toolbox-for-mac
Apache License 2.0
0 stars 0 forks source link

GTMSenTestCase does not catch exceptions other than NSException #64

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a unit test that throws a custom exception not extending NSException
2. Build and run

What is the expected output? What do you see instead?
I would expect the exception to be caught and a description printed out, 
instead the program crashes and I get
*** Terminating app due to uncaught exception of class 'SLError'
terminate called after throwing an instance of 'SLError'

What version of the product are you using? On what operating system?
Revision: 420
iPhone 4.2 project on XCode 3.2.5

Please provide any additional information below.

Original issue reported on code.google.com by alejandr...@gmail.com on 24 Dec 2010 at 12:30

GoogleCodeExporter commented 9 years ago
Also, STAssertThrowsSpecific does not work with non-NSExceptions.

Original comment by alejandr...@gmail.com on 24 Dec 2010 at 12:45

GoogleCodeExporter commented 9 years ago
Out of curiosity why are you throwing exceptions that don't inherit from 
NSException?

http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/Exception
s/Tasks/RaisingExceptions.html

Original comment by dmaclach on 3 Jan 2011 at 8:47

GoogleCodeExporter commented 9 years ago
fyi - 
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Exception
s/Tasks/HandlingExceptions.html

"""Important: Although you can throw and catch objects other than NSException 
objects, the Cocoa frameworks themselves might only catch NSException objects 
for some conditions. So if you throw other types of objects, the Cocoa handlers 
for that exception might not run, with undefined results. (Conversely, 
non-NSException objects that you throw could be caught by some Cocoa handlers.) 
For these reasons, it is recommended that you throw NSException objects only, 
while being prepared to catch exception objects of all types."""

Original comment by thoma...@gmail.com on 3 Jan 2011 at 8:48

GoogleCodeExporter commented 9 years ago
I use exceptions that don't inherit from NSException because I wanted a 
light(er) weight exception class. In particular I don't want to provide a name 
and a reason strings, but I do want to include custom information. Also I want 
to differentiate between my exception and system exceptions via different 
@catch statements -- I don't want to catch system exceptions.

Original comment by alejandr...@gmail.com on 3 Jan 2011 at 10:24