Transport.py 720 Bytes
"""
Common things for all possible transports...
Currently our only transport is TCP but in theory there might be others...

Author: Georg Hopp <ghopp@spamtitan.com>
"""

class Error(Exception):
    """
    This simplifies all the possible transport problems down to two cases.
    Either the transport has failed completely or the remote side has shutdown
    it's endpoint for the operation we are attemting.
    """
    ERR_FAILED       = 1
    ERR_REMOTE_CLOSE = 2

    messages = {
        ERR_FAILED       : 'transport operation failed',
        ERR_REMOTE_CLOSE : 'remote endpoint closed'
    }

    def __init__(self, errno):
        super(Error, self).__init__(Error.messages[errno])
        self.errno = errno