Best practice for exceptions
Best practice for exceptions
- Subject: Best practice for exceptions
- From: Drew McCormack <email@hidden>
- Date: Tue, 26 Feb 2002 18:22:40 +0100
I was wondering if someone with plenty of experience would like to
explain how they utilize exceptions in their cocoa apps. I can never
figure out when I should throw an exception, and when I should, for
example, set a flag and put details of the failure in a string to return
to the caller. Is there a general consensus on this?
For example, I am writing an expression parser. If the parser comes
across a syntax error in the expression, which was entered by the user,
should I throw an exception, or simply return an error code to the
caller, with a message to display to the user. It's not an exception in
the sense that something completely unexpected has happened, since user
error is to be expected. On the other hand, exceptions seem to be more
elegant than setting a failure flag and adding an extra 'message'
argument to function, like in the old days.
Drew
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
... ... ... ... ... ... ... ...
Dr. Drew McCormack
Trade Strategist (www.trade-strategist.com)
Trading simulation software for Mac OS X
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.