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 ProxyPortMetadataNotFound(ProxyPortNotFound): |
42
|
|
|
"""ProxyPortMetadataNotFound.""" |
43
|
|
|
|
44
|
|
|
|
45
|
1 |
|
class ProxyPortDestNotFound(ProxyPortNotFound): |
46
|
|
|
"""ProxyPorDesttNotFound.""" |
47
|
|
|
|
48
|
|
|
|
49
|
1 |
|
class ProxyPortConflict(ProxyPortError): |
50
|
|
|
"""ProxyPortConflict.""" |
51
|
|
|
|
52
|
|
|
|
53
|
1 |
|
class ProxyPortRequired(ProxyPortConflict): |
54
|
|
|
"""ProxyPortRequired.""" |
55
|
|
|
|
56
|
|
|
|
57
|
1 |
|
class ProxyPortAsymmetric(ProxyPortConflict): |
58
|
|
|
"""ProxyPortAsymmetric.""" |
59
|
|
|
|
60
|
|
|
|
61
|
1 |
|
class ProxyPortStatusNotUP(ProxyPortConflict): |
62
|
|
|
"""ProxyPortStatusNotUP.""" |
63
|
|
|
|
64
|
|
|
|
65
|
1 |
|
class ProxyPortSameSourceIntraEVC(ProxyPortConflict): |
66
|
|
|
"""ProxyPortSameSourceIntraEVC. |
67
|
|
|
|
68
|
|
|
Intra EVC UNIs must use different proxy ports. |
69
|
|
|
""" |
70
|
|
|
|
71
|
|
|
|
72
|
1 |
|
class ProxyPortShared(ProxyPortConflict): |
73
|
|
|
"""ProxyPortShared. A shared proxy port isn't supported for now. |
74
|
|
|
Each uni should have its own proxy port""" |
75
|
|
|
|
76
|
|
|
|
77
|
1 |
|
class EVCHasNoINT(EVCError): |
78
|
|
|
"""Exception in case the EVC doesn't have INT enabled.""" |
79
|
|
|
|
80
|
1 |
|
def __init__(self, evc_id: str, message="INT isn't enabled"): |
81
|
1 |
|
super().__init__(evc_id, message) |
82
|
|
|
|
83
|
|
|
|
84
|
1 |
|
class EVCHasINT(EVCError): |
85
|
|
|
"""Exception in case the EVC already has INT enabled.""" |
86
|
|
|
|
87
|
1 |
|
def __init__(self, evc_id: str, message="INT is already enabled"): |
88
|
1 |
|
super().__init__(evc_id, message) |
89
|
|
|
|
90
|
|
|
|
91
|
1 |
|
class EVCNotFound(EVCError): |
92
|
|
|
"""Exception in case the EVC isn't found.""" |
93
|
|
|
|
94
|
1 |
|
def __init__(self, evc_id: str, message="not found"): |
95
|
1 |
|
super().__init__(evc_id, message) |
96
|
|
|
|
97
|
|
|
|
98
|
1 |
|
class FlowsNotFound(EVCError): |
99
|
|
|
"""Exception in case the EVC's flows are not there.""" |
100
|
|
|
|
101
|
1 |
|
def __init__(self, evc_id: str, message="flows not found"): |
102
|
1 |
|
super().__init__(evc_id, message) |
103
|
|
|
|
104
|
|
|
|
105
|
1 |
|
class PriorityOverflow(EVCError): |
106
|
|
|
"""Exception in case the EVC's can't set a higher priority.""" |
107
|
|
|
|
108
|
1 |
|
def __init__(self, evc_id: str, message="setting a higher priority would overflow"): |
109
|
|
|
super().__init__(evc_id, message) |
110
|
|
|
|