Re: Which exception handling system should I use?
Re: Which exception handling system should I use?
- Subject: Re: Which exception handling system should I use?
- From: Ondra Cada <email@hidden>
- Date: Mon, 24 Apr 2006 16:38:30 +0200
Matteo,
On 24.4.2006, at 16:12, Matteo Manferdini wrote:
Hi everyone, I dicovered that Objective-C and Cocoa have two
different systems for handling exceptions: the first is described
in the "Objective-C programming language" guide (http://
developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
Articles/chapter_4_section_9.html), the second in the "Exception
programming topics for Cocoa" document (http://developer.apple.com/
documentation/Cocoa/Conceptual/Exceptions/Exceptions.html)
They seem to me the same thing, so I was wondering which one to use
and why there are two systems for the same thing.
Both the systems are compatible both ways, so you can use whatever
you like, even mixed.
The new system advantages and disadvantages (at least those of them I
can recall offhand :))
+ more convenient (@finally, can 'return' out)
+ more safe ('return' out won't fail)
- has to be explicitly switched on
- not portable to older systems
- problem with breaking at (objc_exception_throw can be used, but
unlike raise, there's no guarantee for future)
+ allows to throw any object (not necessarily an NSException--if
doing so, beware compatibility with older code!)
- does not allow dynamic expansion (you cannot override
objc_exception_throw by subclass/category/poseAsClass).
I actually am using it for its convenience and failproofness, though
I kind of dislike it for the -'s above. Pity they did not design it a
bit differently...
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden