Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTMSenTestCase does not catch exceptions other than NSException #64

Closed
GoogleCodeExporter opened this issue Apr 21, 2015 · 4 comments
Closed

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

Also, STAssertThrowsSpecific does not work with non-NSExceptions.

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

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants