|
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
|
|
|
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 ProxyPortStatusNotUP(ProxyPortError): |
|
42
|
|
|
"""ProxyPortStatusNotUP.""" |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
1 |
|
class EVCHasNoINT(EVCError): |
|
46
|
|
|
"""Exception in case the EVC doesn't have INT enabled.""" |
|
47
|
|
|
|
|
48
|
1 |
|
def __init__(self, evc_id: str, message="INT isn't enabled"): |
|
49
|
|
|
super().__init__(evc_id, message) |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
1 |
|
class EVCHasINT(EVCError): |
|
53
|
|
|
"""Exception in case the EVC already has INT enabled.""" |
|
54
|
|
|
|
|
55
|
1 |
|
def __init__(self, evc_id: str, message="INT is already enabled"): |
|
56
|
|
|
super().__init__(evc_id, message) |
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
1 |
|
class EVCNotFound(EVCError): |
|
60
|
|
|
"""Exception in case the EVC isn't found.""" |
|
61
|
|
|
|
|
62
|
1 |
|
def __init__(self, evc_id: str, message="not found"): |
|
63
|
|
|
super().__init__(evc_id, message) |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
1 |
|
class FlowsNotFound(EVCError): |
|
67
|
|
|
"""Exception in case the EVC's flows are not there.""" |
|
68
|
|
|
|
|
69
|
1 |
|
def __init__(self, evc_id: str, message="flows not found"): |
|
70
|
|
|
super().__init__(evc_id, message) |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
1 |
|
class PriorityOverflow(EVCError): |
|
74
|
|
|
"""Exception in case the EVC's can't set a higher priority.""" |
|
75
|
|
|
|
|
76
|
1 |
|
def __init__(self, evc_id: str, message="setting a higher priority would overflow"): |
|
77
|
|
|
super().__init__(evc_id, message) |
|
78
|
|
|
|