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 ProxyPortShared(ProxyPortError): |
57
|
|
|
"""ProxyPortShared. A shared proxy port isn't supported for now. |
58
|
|
|
Each uni should have its own proxy port""" |
59
|
|
|
|
60
|
|
|
|
61
|
1 |
|
class EVCHasNoINT(EVCError): |
62
|
|
|
"""Exception in case the EVC doesn't have INT enabled.""" |
63
|
|
|
|
64
|
1 |
|
def __init__(self, evc_id: str, message="INT isn't enabled"): |
65
|
1 |
|
super().__init__(evc_id, message) |
66
|
|
|
|
67
|
|
|
|
68
|
1 |
|
class EVCHasINT(EVCError): |
69
|
|
|
"""Exception in case the EVC already has INT enabled.""" |
70
|
|
|
|
71
|
1 |
|
def __init__(self, evc_id: str, message="INT is already enabled"): |
72
|
|
|
super().__init__(evc_id, message) |
73
|
|
|
|
74
|
|
|
|
75
|
1 |
|
class EVCNotFound(EVCError): |
76
|
|
|
"""Exception in case the EVC isn't found.""" |
77
|
|
|
|
78
|
1 |
|
def __init__(self, evc_id: str, message="not found"): |
79
|
|
|
super().__init__(evc_id, message) |
80
|
|
|
|
81
|
|
|
|
82
|
1 |
|
class FlowsNotFound(EVCError): |
83
|
|
|
"""Exception in case the EVC's flows are not there.""" |
84
|
|
|
|
85
|
1 |
|
def __init__(self, evc_id: str, message="flows not found"): |
86
|
1 |
|
super().__init__(evc_id, message) |
87
|
|
|
|
88
|
|
|
|
89
|
1 |
|
class PriorityOverflow(EVCError): |
90
|
|
|
"""Exception in case the EVC's can't set a higher priority.""" |
91
|
|
|
|
92
|
1 |
|
def __init__(self, evc_id: str, message="setting a higher priority would overflow"): |
93
|
|
|
super().__init__(evc_id, message) |
94
|
|
|
|