Code Coverage

Cobertura Coverage Report > n2vc >

exceptions.py

Trend

Classes100%
 
Lines66%
   
Conditionals100%
 

File Coverage summary

NameClassesLinesConditionals
exceptions.py
100%
1/1
66%
38/58
100%
0/0

Coverage Breakdown by Class

NameLinesConditionals
exceptions.py
66%
38/58
N/A

Source

n2vc/exceptions.py
1 # Copyright 2019 Canonical Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #     Unless required by applicable law or agreed to in writing, software
10 #     distributed under the License is distributed on an "AS IS" BASIS,
11 #     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #     See the License for the specific language governing permissions and
13 #     limitations under the License.
14
15
16 1 class JujuCharmNotFound(Exception):
17     """The Charm can't be found or is not readable."""
18
19
20 1 class JujuApplicationExists(Exception):
21     """The Application already exists."""
22
23
24 1 class N2VCPrimitiveExecutionFailed(Exception):
25     """Something failed while attempting to execute a primitive."""
26
27
28 1 class NetworkServiceDoesNotExist(Exception):
29     """The Network Service being acted against does not exist."""
30
31
32 1 class PrimitiveDoesNotExist(Exception):
33     """The Primitive being executed does not exist."""
34
35
36 1 class NoRouteToHost(Exception):
37     """There was no route to the specified host."""
38
39
40 1 class AuthenticationFailed(Exception):
41     """The authentication for the specified user failed."""
42
43
44 1 class MethodNotImplemented(Exception):
45     """The method is not implemented."""
46
47
48 1 class N2VCException(Exception):
49     """
50     N2VC exception base class
51     """
52
53 1     def __init__(self, message: str = ""):
54 1         Exception.__init__(self, message)
55 1         self.message = message
56
57 1     def __str__(self):
58 0         return self.message
59
60 1     def __repr__(self):
61 0         return "{}({})".format(type(self), self.message)
62
63
64 1 class N2VCBadArgumentsException(N2VCException):
65     """
66     Bad argument values exception
67     """
68
69 1     def __init__(self, message: str = "", bad_args: list = None):
70 0         N2VCException.__init__(self, message=message)
71 0         self.bad_args = bad_args
72
73 1     def __str__(self):
74 0         return "<{}> Bad arguments: {} -> {}".format(
75             type(self), super().__str__(), self.bad_args
76         )
77
78
79 1 class N2VCConnectionException(N2VCException):
80     """
81     Error connecting to VCA
82     """
83
84 1     def __init__(self, message: str = "", url: str = None):
85 0         N2VCException.__init__(self, message=message)
86 0         self.url = url
87
88 1     def __str__(self):
89 0         return "<{}> Connection to {} failed: {}".format(
90             type(self), self.url, super().__str__()
91         )
92
93
94 1 class N2VCTimeoutException(N2VCException):
95     """
96     Timeout
97     """
98
99 1     def __init__(self, message: str = "", timeout: str = ""):
100 1         N2VCException.__init__(self, message=message)
101 1         self.timeout = timeout
102
103 1     def __str__(self):
104 0         return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__())
105
106
107 1 class N2VCExecutionException(N2VCException):
108     """
109     Error executing primitive
110     """
111
112 1     def __init__(self, message: str = "", primitive_name: str = ""):
113 0         N2VCException.__init__(self, message=message)
114 0         self.primitive_name = primitive_name
115
116 1     def __str__(self):
117 0         return "<{}> Error executing primitive {} failed: {}".format(
118             type(self), self.primitive_name, super().__str__()
119         )
120
121
122 1 class N2VCInvalidCertificate(N2VCException):
123     """
124     Invalid certificate
125     """
126
127 1     def __init__(self, message: str = ""):
128 0         N2VCException.__init__(self, message=message)
129
130 1     def __str__(self):
131 0         return "<{}> Invalid certificate: {}".format(type(self), super().__str__())
132
133
134 1 class N2VCNotFound(N2VCException):
135     """
136     Not found
137     """
138
139 1     def __init__(self, message: str = ""):
140 0         N2VCException.__init__(self, message=message)
141
142 1     def __str__(self):
143 0         return "<{}> Not found: {}".format(type(self), super().__str__())
144
145
146 1 class K8sException(Exception):
147     """
148     K8s exception
149     """
150
151 1     def __init__(self, message: str):
152 0         Exception.__init__(self, message)
153 0         self._message = message
154
155 1     def __str__(self):
156 0         return self._message
157
158 1     def __repr__(self):
159 0         return self._message