Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | """ |
||
9 | class UaStatusCodeError(UaError): |
||
10 | 1 | """ |
|
11 | 1 | This exception is raised when a bad status code is encountered. |
|
12 | |||
13 | It exposes the status code number in the `code' property, so the |
||
14 | 1 | user can distinguish between the different status codes and maybe |
|
15 | 1 | handle some of them. |
|
16 | |||
17 | The list of status error codes can be found in opcua.ua.status_codes. |
||
18 | """ |
||
19 | def __init__(self, code): |
||
20 | """ |
||
21 | :param code: The code of the exception. (Should be a number.) |
||
22 | """ |
||
23 | UaError.__init__(self, code) |
||
24 | |||
25 | def __str__(self): |
||
26 | # import here to avoid circular import problems |
||
27 | import opcua.ua.status_codes as status_codes |
||
28 | |||
29 | return "{1}({0})".format(*status_codes.get_name_and_doc(self.code)) |
||
30 | |||
31 | @property |
||
32 | def code(self): |
||
33 | """ |
||
34 | The code of the status error. |
||
35 | """ |
||
36 | return self.args[0] |
||
37 | |||
40 |