Completed
Push — master ( 7074ac...9d2788 )
by Olivier
02:15
created

UaStatusCodeError.__init__()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 5
ccs 0
cts 0
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
"""
2
Define exceptions to be raised at various places in the stack
3
"""
4
5
class UaError(RuntimeError):
6 1
    pass
7 1
8
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
38
class UaStringParsingError(UaError):
39
    pass
40