Passed
Push — master ( 9bde40...c0a17f )
by Vinicius
02:56 queued 18s
created

build.exceptions   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Test Coverage

Coverage 93.55%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 89
ccs 29
cts 31
cp 0.9355
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A EVCError.__init__() 0 4 1
A UnrecoverableError.__init__() 0 4 1
A EVCHasINT.__init__() 0 2 1
A EVCNotFound.__init__() 0 2 1
A FlowsNotFound.__init__() 0 2 1
A PriorityOverflow.__init__() 0 2 1
A EVCHasNoINT.__init__() 0 2 1
A EVCError.__str__() 0 2 1
1
""" Customized Exceptions """
2
3
4 1
class UnrecoverableError(Exception):
5
    """UnrecoverableError.
6
7
    Base exception for any custom exception that shouldn't be retried.
8
    """
9
10 1
    def __init__(self, message: str) -> None:
11
        """Constructor of UnrecoverableError."""
12 1
        self.message = message
13 1
        super().__init__(self.message)
14
15
16 1
class EVCError(UnrecoverableError):
17
    """Exception raised for unrecoverable EVC errors
18
19
    Attributes:
20
        evc_id -- evc ID provided
21
        message -- explanation of the error
22
    """
23
24 1
    def __init__(self, evc_id: str, message: str):
25 1
        self.evc_id = evc_id
26 1
        self.message = message
27 1
        super().__init__(self.message)
28
29 1
    def __str__(self):
30 1
        return f"EVC {self.evc_id} {self.message}"
31
32
33 1
class ProxyPortError(EVCError):
34
    """ProxyPortError."""
35
36
37 1
class ProxyPortNotFound(ProxyPortError):
38
    """ProxyPortNotFound."""
39
40
41 1
class ProxyPortDestNotFound(ProxyPortError):
42
    """ProxyPorDesttNotFound."""
43
44
45 1
class ProxyPortStatusNotUP(ProxyPortError):
46
    """ProxyPortStatusNotUP."""
47
48
49 1
class ProxyPortSameSourceIntraEVC(ProxyPortError):
50
    """ProxyPortSameSourceIntraEVC.
51
52
    Intra EVC UNIs must use different proxy ports.
53
    """
54
55
56 1
class EVCHasNoINT(EVCError):
57
    """Exception in case the EVC doesn't have INT enabled."""
58
59 1
    def __init__(self, evc_id: str, message="INT isn't enabled"):
60 1
        super().__init__(evc_id, message)
61
62
63 1
class EVCHasINT(EVCError):
64
    """Exception in case the EVC already has INT enabled."""
65
66 1
    def __init__(self, evc_id: str, message="INT is already enabled"):
67
        super().__init__(evc_id, message)
68
69
70 1
class EVCNotFound(EVCError):
71
    """Exception in case the EVC isn't found."""
72
73 1
    def __init__(self, evc_id: str, message="not found"):
74
        super().__init__(evc_id, message)
75
76
77 1
class FlowsNotFound(EVCError):
78
    """Exception in case the EVC's flows are not there."""
79
80 1
    def __init__(self, evc_id: str, message="flows not found"):
81 1
        super().__init__(evc_id, message)
82
83
84 1
class PriorityOverflow(EVCError):
85
    """Exception in case the EVC's can't set a higher priority."""
86
87 1
    def __init__(self, evc_id: str, message="setting a higher priority would overflow"):
88
        super().__init__(evc_id, message)
89