mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-06 20:14:48 +01:00
32 lines
995 B
Python
32 lines
995 B
Python
#!/usr/bin/env python
|
|
from exceptions import Exception
|
|
|
|
class ProtocolError(Exception):
|
|
""" The base class for all exceptions in this package """
|
|
def __init__(self, msg):
|
|
Exception.__init__(self, msg)
|
|
|
|
class PacketError(ProtocolError):
|
|
""" Errors with creating/interpreting packets """
|
|
def __init__(self, msg):
|
|
ProtocolError.__init__(self, msg)
|
|
|
|
class PathError(ProtocolError):
|
|
def __init__(self, msg):
|
|
Exception.__init__(self, msg)
|
|
|
|
class ControlError(ProtocolError):
|
|
def __init__(self, query=None, response=None, desc=None):
|
|
self.query = query
|
|
self.response = response
|
|
Exception.__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"
|