Fix exception handling

There may be some cases where we call ManagerError and pass 'details'
as a paramter instead of manager. This makes the code more robust.

Change-Id: I03e4ccf0c1a074798ce364bd7ffd647b703196d1
This commit is contained in:
Gary Kotton 2016-11-25 06:12:34 -08:00
parent 6bd068859e
commit a18187dab8
1 changed files with 6 additions and 4 deletions

View File

@ -56,11 +56,13 @@ class ManagerError(NsxLibException):
"for %(operation)s %(details)s")
def __init__(self, **kwargs):
kwargs['details'] = (': %s' % kwargs['details']
if 'details' in kwargs
else '')
details = kwargs.get('details', '')
kwargs['details'] = ': %s' % details
super(ManagerError, self).__init__(**kwargs)
self.msg = self.message % kwargs
try:
self.msg = self.message % kwargs
except KeyError:
self.msg = details
class ResourceNotFound(ManagerError):