1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 """
16 Defines the errors that libprs500 generates.
17
18 G{classtree ProtocolError}
19 """
20 from exceptions import Exception
21
23 """ The base class for all exceptions in this package """
26
28 """ Errors with creating/interpreting packets """
29
31 """ Errors caused by invalid arguments to a public interface function """
32
34 """ When a user supplies an incorrect/invalid path """
35
37 """ Errors in Command/Response pairs while communicating with the device """
38 - def __init__(self, query=None, response=None, desc=None):
39 self.query = query
40 self.response = response
41 Exception.__init__(self, desc)
42
44 if self.query and self.response:
45 return "Got unexpected response:\n" + \
46 "query:\n"+str(self.query.query)+"\n"+\
47 "expected:\n"+str(self.query.response)+"\n" +\
48 "actual:\n"+str(self.response)
49 if self.desc:
50 return self.desc
51 return "Unknown control error occurred"
52