Skip to content

Commit bde798c

Browse files
petrutlucian94alexpilotti
authored andcommitted
[trivial] Fix attribute error handling
When failing to access an MI object attribute, we check if that attribute is in fact a method. If that fails as well, we're looking for an "MI_RESULT_METHOD_NOT_FOUND" error code. The issue is that we aren't properly retrieving the error code. It will still throw an attribute error (for which reason it wasn't a big concern), but the trace can be misleading and not user friendly: http://paste.openstack.org/raw/755512/ This change will fix this issue by correctly retrieving the error code.
1 parent f5ebd24 commit bde798c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

wmi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def __getattr__(self, name):
294294
try:
295295
return _Method(self._conn, self, name)
296296
except mi.error as err:
297-
if err.message['mi_result'] == (
297+
if err.args[0].get('mi_result') == (
298298
mi_error.MI_RESULT_METHOD_NOT_FOUND):
299299
err_msg = ("'%(cls_name)s' has no attribute "
300300
"'%(attr_name)s'.")

0 commit comments

Comments
 (0)