On 30 Aug 2005, at 10:52, Joe Van Dyk wrote:
> When should you define your own exceptions? Any rules of thumb?
I define custom exceptions when I need to differentiate them from the
built-in exceptions.
> I'm writing an application that runs on a computer and listens for
> requests to start, kill, and view log files for other applications on
> that computer. Say I get a request to start an application on that
> computer and the requested executable doesn't exist. Should I throw a
> custom exception then? Or, say an application dies unexpectedly.
> What should I use for an exception then?
Sometimes an exception with a message is enough. Other times I need
to know the difference between two RuntimeErrors with different
messages.
I create my own exceptions for the second case because rescue
FooError is easier than reading exception messages.
--
Eric Hodel -
-
http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04