Logo Search packages:      
Sourcecode: calibre version File versions

errors.py

__license__   = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
"""
Defines the errors that the device drivers generate.

G{classtree ProtocolError}
"""

00009 class ProtocolError(Exception):
    """ The base class for all exceptions in this package """
    def __init__(self, msg):
        Exception.__init__(self, msg)

00014 class TimeoutError(ProtocolError):
    """ There was a timeout during communication """
    def __init__(self, func_name):
        ProtocolError.__init__(self, \
        "There was a timeout while communicating with the device in function: "\
        +func_name)

00021 class DeviceError(ProtocolError):
    """ Raised when device is not found """
    def __init__(self, msg=None):
        if msg is None:
            msg = "Unable to find SONY Reader. Is it connected?" 
        ProtocolError.__init__(self, msg)

00028 class DeviceBusy(ProtocolError):
    """ Raised when device is busy """
    def __init__(self, uerr=""):
        ProtocolError.__init__(self, "Device is in use by another application:"\
                               "\nUnderlying error:" + str(uerr))

00034 class DeviceLocked(ProtocolError):
    """ Raised when device has been locked """
    def __init__(self):
        ProtocolError.__init__(self, "Device is locked")

00039 class PacketError(ProtocolError):
    """ Errors with creating/interpreting packets """

00042 class FreeSpaceError(ProtocolError):
    """ Errors caused when trying to put files onto an overcrowded device """

00045 class ArgumentError(ProtocolError):
    """ Errors caused by invalid arguments to a public interface function """

00048 class PathError(ArgumentError):
    """ When a user supplies an incorrect/invalid path """
    def __init__(self, msg, path=None):
        ArgumentError.__init__(self, msg)
        self.path = path

00054 class ControlError(ProtocolError):
    """ Errors in Command/Response pairs while communicating with the device """
    def __init__(self, query=None, response=None, desc=None):
        self.query = query
        self.response = response
        ProtocolError.__init__(self, desc)
    
    def __str__(self):    
        if self.query and self.response:
            return "Got unexpected response:\n" + \
           "query:\n"+str(self.query.query)+"\n"+\
           "expected:\n"+str(self.query.response)+"\n" +\
           "actual:\n"+str(self.response)
        if self.desc:
            return self.desc
        return "Unknown control error occurred"

Generated by  Doxygen 1.6.0   Back to index