From: garciadeblas Date: Fri, 22 Nov 2019 12:39:20 +0000 (+0100) Subject: Merge branch 'feature7928' X-Git-Tag: v7.0.0rc1~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F8214%2F1;p=osm%2FN2VC.git Merge branch 'feature7928' Change-Id: Iccb5e5fa854394da873b9c8c3bade3358f9db6f0 Signed-off-by: garciadeblas --- 9ae4d929c2b739d146e3e27388dc4825ca046e50 diff --cc n2vc/exceptions.py index a63d6f9,4b83e3f..35962b2 --- a/n2vc/exceptions.py +++ b/n2vc/exceptions.py @@@ -40,10 -40,80 +40,90 @@@ class AuthenticationFailed(Exception) """The authentication for the specified user failed.""" +class InvalidCACertificate(Exception): + """The CA Certificate is not valid.""" + + +class NotImplemented(Exception): + """The method is not implemented.""" + ++ + class N2VCException(Exception): + """ + N2VC exception base class + """ + + def __init__(self, message: str = ''): + Exception.__init__(self, message) + self.message = message + + def __str__(self): + return self.message + + def __repr__(self): + return '{}({})'.format(type(self), self.message) + + + class N2VCBadArgumentsException(N2VCException): + """ + Bad argument values exception + """ + + 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) + + + class N2VCConnectionException(N2VCException): + """ + Error connecting to VCA + """ + + 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__()) + + + class N2VCTimeoutException(N2VCException): + """ + Timeout + """ + + 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__()) + + + class N2VCExecutionException(N2VCException): + """ + Error executing primitive + """ + + 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__()) + ++ + class N2VCInvalidCertificate(N2VCException): + """ + Invalid certificate + """ + + def __init__(self, message: str = ''): + N2VCException.__init__(self, message=message) + + def __str__(self): + return '<{}> Invalid certificate: {}'.format(type(self), super().__str__()) ++