Recommended exception method for modules?

Grant Edwards ge at nowhere.none
Thu Oct 5 18:17:26 EDT 2000


In article <n8apts0ral3s3gm5rksmh4bouqjdu3ckcv at 4ax.com>, Toby Dickenson wrote:

>> 3) a class for each type of error with value(s) that further
>>    explain what is wrong:
>>
>>    class PosixSerialBaudError(Exception):
>>        [...]
>>         
>>    if not validBaud(r):
>>        raise PosixSerialBaudError(r)
>>
>>    [this last one could be done as a subclass of a general
>>     PosixSerialError class, -- that way somebody can catch
>>     either all of my exceptions or just individual ones.
>>     Right?]
>
>Possibly a PosixSerialBaudError is a little too specific.

I agree.  For now I'm just raising ValueError with an
explanitory argument.

-- 
Grant Edwards                   grante             Yow!  NOW, I'm supposed
                                  at               to SCRAMBLE two, and HOLD
                               visi.com            th' MAYO!!



More information about the Python-list mailing list