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:
@@ -56,11 +56,13 @@ class ManagerError(NsxLibException):
|
|||||||
"for %(operation)s %(details)s")
|
"for %(operation)s %(details)s")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
kwargs['details'] = (': %s' % kwargs['details']
|
details = kwargs.get('details', '')
|
||||||
if 'details' in kwargs
|
kwargs['details'] = ': %s' % details
|
||||||
else '')
|
|
||||||
super(ManagerError, self).__init__(**kwargs)
|
super(ManagerError, self).__init__(**kwargs)
|
||||||
|
try:
|
||||||
self.msg = self.message % kwargs
|
self.msg = self.message % kwargs
|
||||||
|
except KeyError:
|
||||||
|
self.msg = details
|
||||||
|
|
||||||
|
|
||||||
class ResourceNotFound(ManagerError):
|
class ResourceNotFound(ManagerError):
|
||||||
|
|||||||
Reference in New Issue
Block a user