Passed
Push — master ( 7f62ad...2ec8a9 )
by Vinicius
02:07 queued 13s
created

build.exceptions.EvcDoesNotExist.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 3
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
""" Customized Exceptions """
2
3
4
class ErrorBase(Exception):
5
    """Exception raised for situations where the
6
    EVC provided is non-existent.
7
8
    Attributes:
9
        evc_id -- evc ID provided
10
        message -- explanation of the error
11
    """
12
13
    def __init__(self, evc_id, message):
14
        self.evc_id = evc_id
15
        self.message = message
16
        super().__init__(self.message)
17
18
    def __str__(self):
19
        return f"EVC {self.evc_id} {self.message}"
20
21
22
class NoProxyPortsAvailable(ErrorBase):
23
    """Exception in case an UNI doesn't have a proxy port configured or operational.
24
    That's a warning."""
25
26
    def __init__(self, evc_id, message="no proxy ports available."):
27
        super().__init__(evc_id, message)
28
29
30
class EvcHasNoINT(ErrorBase):
31
    """Exception in case the EVC doesn't have INT/telemetry enabled but it was
32
    treated as if. That's a warning."""
33
34
    def __init__(self, evc_id, message="INT was not enabled for this EVC."):
35
        super().__init__(evc_id, message)
36
37
38
class FlowsNotFound(ErrorBase):
39
    """Exception in case the EVC's flows are not there. Used for testing and debugging.
40
    That's an warning. Maybe it requires some investigation."""
41
42
    def __init__(self, evc_id, message="Flow not found."):
43
        super().__init__(evc_id, message)
44