Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Checked Exceptions in objc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checked Exceptions in objc



Sorry for the multiple posts everyone. ISP problems.

To be more specific, I am using the new-style exceptions (@throw, @try, @catch) with subclasses of NSException. The only way to know right now if I'm @catch-ing all exceptions is to look at the documentation and ensure I'm catching everything I need to. In Java, I can just:

(int) someFunc( someType someArg ) throws MyException, YourException

If I then fail to catch MyException and YourException when calling someFunc(), the compiler complains, making it easy to fix the problem. If I forget in obj-c, I don't know until something causes the exception to throw during runtime.

I haven't had much luck finding a throws keyword to do this (pretty sure it doesn't exist). Sans that, does anyone have a design pattern or programming habit I can adopt to do basically the same thing?

Thanks again,

Mike Manzano
http://proto.skootit.com


On May 14, 2007, at 6:55 ☽ PDT, Jonathan deWerd wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The short answer: you can't.

But why do you need to know this? Perhaps if we knew more about what you were trying to do we could give you a better answer.

Exceptional behavior is handled very differently in Objective C and Java, so if you haven't already read the documentation dealing with use of exceptions, errors, and nil (look in topics of NSException and NSError documentation) then it might be helpful.

Good luck with your project,
Jonathan


On May 14, 2007, at 6:54 PM, Mike Manzano wrote:

Does anyone know how to force the compiler to check that a specified exception is thrown from a method?

I'm looking for something similar to the Java "throws" keyword.

Thanks!

Mike

_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Checked Exceptions in objc (From: Mike Manzano <email@hidden>)
 >Re: Checked Exceptions in objc (From: Jonathan deWerd <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.