Gennady
11/13/2003 3:55:00 PM
It is also convenient to define your own exception, even without any
extra information besides the message, if you need to raise it in
several places. In the very least it removes the message duplication
and facilitates in debugging.
Gennady.
Sincerely,
Gennady Bystritsky
On Nov 12, 2003, at 8:04 PM, David Naseby wrote:
>
>> -----Original Message-----
>> From: John W. Long [mailto:ws@johnwlong.com]
>
>> When is it a good idea to subclass and create my own error
>> class?
>
> Your testing example was good, and similarly, it also aids in
> debugging down
> the line. For example, if you have a method that opens a file and
> manipulates the data, its generally a good idea to know if an exception
> coming out of that method is related to the file ops or due to some
> use of
> the standard library, or from a defined bad operation from your code
> (error
> condition). Defining a derived exception class is a bit safer for
> client
> code to handle, rather than just parsing the exception message.
>
> David
>
>