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

build.exceptions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 44
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A ErrorBase.__str__() 0 2 1
A ErrorBase.__init__() 0 4 1
A FlowsNotFound.__init__() 0 2 1
A EvcHasNoINT.__init__() 0 2 1
A NoProxyPortsAvailable.__init__() 0 2 1
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