X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fexceptions.py;h=09f3573c6d3b03ddba952ae5f475d2a0e9493d2b;hp=4b83e3ffa97c79b764058eaab1f01e5255ce78f9;hb=bc8a903f95a2e7e03ab290187a53c69c0e0a5ca6;hpb=ac4e0dec95b3f18b57ee176136cb9885a8f3e2e1 diff --git a/n2vc/exceptions.py b/n2vc/exceptions.py index 4b83e3f..09f3573 100644 --- a/n2vc/exceptions.py +++ b/n2vc/exceptions.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + class JujuCharmNotFound(Exception): """The Charm can't be found or is not readable.""" @@ -40,12 +41,16 @@ class AuthenticationFailed(Exception): """The authentication for the specified user failed.""" +class MethodNotImplemented(Exception): + """The method is not implemented.""" + + class N2VCException(Exception): """ N2VC exception base class """ - def __init__(self, message: str = ''): + def __init__(self, message: str = ""): Exception.__init__(self, message) self.message = message @@ -53,7 +58,7 @@ class N2VCException(Exception): return self.message def __repr__(self): - return '{}({})'.format(type(self), self.message) + return "{}({})".format(type(self), self.message) class N2VCBadArgumentsException(N2VCException): @@ -61,12 +66,14 @@ class N2VCBadArgumentsException(N2VCException): Bad argument values exception """ - def __init__(self, message: str = '', bad_args: list = None): + def __init__(self, message: str = "", bad_args: list = None): N2VCException.__init__(self, message=message) self.bad_args = bad_args def __str__(self): - return '<{}> Bad arguments: {} -> {}'.format(type(self), super().__str__(), self.bad_args) + return "<{}> Bad arguments: {} -> {}".format( + type(self), super().__str__(), self.bad_args + ) class N2VCConnectionException(N2VCException): @@ -74,12 +81,14 @@ class N2VCConnectionException(N2VCException): Error connecting to VCA """ - def __init__(self, message: str = '', url: str = None): + def __init__(self, message: str = "", url: str = None): N2VCException.__init__(self, message=message) self.url = url def __str__(self): - return '<{}> Connection to {} failed: {}'.format(type(self), self.url, super().__str__()) + return "<{}> Connection to {} failed: {}".format( + type(self), self.url, super().__str__() + ) class N2VCTimeoutException(N2VCException): @@ -87,12 +96,12 @@ class N2VCTimeoutException(N2VCException): Timeout """ - def __init__(self, message: str = '', timeout: str = ''): + def __init__(self, message: str = "", timeout: str = ""): N2VCException.__init__(self, message=message) self.timeout = timeout def __str__(self): - return '<{}> {} timeout: {}'.format(type(self), self.timeout, super().__str__()) + return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__()) class N2VCExecutionException(N2VCException): @@ -100,20 +109,51 @@ class N2VCExecutionException(N2VCException): Error executing primitive """ - def __init__(self, message: str = '', primitive_name: str = ''): + def __init__(self, message: str = "", primitive_name: str = ""): N2VCException.__init__(self, message=message) self.primitive_name = primitive_name def __str__(self): - return '<{}> Error executing primitive {} failed: {}'.format(type(self), self.primitive_name, super().__str__()) + return "<{}> Error executing primitive {} failed: {}".format( + type(self), self.primitive_name, super().__str__() + ) + class N2VCInvalidCertificate(N2VCException): """ Invalid certificate """ - def __init__(self, message: str = ''): + def __init__(self, message: str = ""): + N2VCException.__init__(self, message=message) + + def __str__(self): + return "<{}> Invalid certificate: {}".format(type(self), super().__str__()) + + +class N2VCNotFound(N2VCException): + """ + Not found + """ + + def __init__(self, message: str = ""): N2VCException.__init__(self, message=message) def __str__(self): - return '<{}> Invalid certificate: {}'.format(type(self), super().__str__()) + return "<{}> Not found: {}".format(type(self), super().__str__()) + + +class K8sException(Exception): + """ + K8s exception + """ + + def __init__(self, message: str): + Exception.__init__(self, message) + self._message = message + + def __str__(self): + return self._message + + def __repr__(self): + return self._message