diff options
author | Shawn Hartsock <hartsocks@vmware.com> | 2014-03-04 15:33:15 -0500 |
---|---|---|
committer | Joe Gordon <joe.gordon0@gmail.com> | 2014-03-07 12:12:43 -0800 |
commit | 1c6898efecd7d78855efcb22d9c38d6127339000 (patch) | |
tree | f0e3897f7baed2ab6566ab8995d103d313bfbc53 /nova/virt/vmwareapi/error_util.py | |
parent | aeda1f6e64f77cd8e54b434be8083f5f6e66237c (diff) | |
download | nova-1c6898efecd7d78855efcb22d9c38d6127339000.tar.gz |
VMware: VimException __str__ attempts to concatenate string to list
Forces the correct parameter use in VimException and VimFaultException
both exceptions have similar signatures but very different uses. This
change forces a developer to deal with misuse of the exceptions
early in their development cycle (provided the do due dilligence with
their testing.)
Closes-bug: 1287884
Change-Id: I34753382677e3315ea4a71cfe9b3b82e9f9159bb
Diffstat (limited to 'nova/virt/vmwareapi/error_util.py')
-rw-r--r-- | nova/virt/vmwareapi/error_util.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/nova/virt/vmwareapi/error_util.py b/nova/virt/vmwareapi/error_util.py index 44aab09f9b..f04033caf6 100644 --- a/nova/virt/vmwareapi/error_util.py +++ b/nova/virt/vmwareapi/error_util.py @@ -38,11 +38,16 @@ class VimException(Exception): def __init__(self, exception_summary, excep): Exception.__init__(self) - self.exception_summary = exception_summary + if isinstance(exception_summary, list): + # we need this to protect against developers using + # this method like VimFaultException + raise ValueError("exception_summary must not be a list") + + self.exception_summary = str(exception_summary) self.exception_obj = excep def __str__(self): - return self.exception_summary + str(self.exception_obj) + return self.exception_summary + ": " + str(self.exception_obj) class SessionOverLoadException(VimException): @@ -65,6 +70,8 @@ class VimFaultException(Exception): def __init__(self, fault_list, excep): Exception.__init__(self) + if not isinstance(fault_list, list): + raise ValueError("fault_list must be a list") self.fault_list = fault_list self.exception_obj = excep |