Changeset 489

Show
Ignore:
Timestamp:
2006-02-06 13:24:33 (3 years ago)
Author:
schwa
Message:
Exception hierarchy changes
===========================

Summary
-------

`TimeShiftError` no longer inherits directly from `FTPError` but
instead via `InternalError`.

`ParserError` used to inherit from `FTPOSError`. This base class
isn't one anymore. Instead, `ParserError` inherits from
`InternalError` (which inherits directly from `FTPError`).

The two changes above may break client code.

TimeShiftError
--------------

In the case of `TimeShiftError`, if you check both `InternalError`
and `TimeShiftError` you must check the more specialized first:

try:
    ...
except TimeShiftError:
    ...
except InternalError:
    ...

ParserError
-----------

Regarding `ParserError`, if you have previously checked for
`FTPOSError` (in your thoughts including `ParserError`), use now

try:
    ...
except (FTPOSError, ParserError):
    ...

The parenthesis are important!

If you checked for `InternalError` and don't want to handle
`ParserError` in the `except` clause for `InternalError`, use

try:
    ...
except ParserError:
    ...
except InternalError:
    ...
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ftp_error.py

    r482 r489  
    5959class RootDirError(InternalError): pass 
    6060class InaccessibleLoginDirError(InternalError): pass 
    61  
    62 class TimeShiftError(FTPError): pass 
     61class TimeShiftError(InternalError): pass 
     62class ParserError(InternalError): pass 
    6363 
    6464class FTPOSError(FTPError, OSError): pass 
    6565class TemporaryError(FTPOSError): pass 
    6666class PermanentError(FTPOSError): pass 
    67 class ParserError(FTPOSError): pass 
    6867 
    6968#XXX Do you know better names for `_try_with_oserror` and