Add more useful information from exception
When the module faces API exception we can give much more useful information to the user. Let us do this for the modules inheriting from the base class, since all modules should do this at some point in time Change-Id: I5f1ef01765829900334aa2ecae5dab3ba96f1a49
This commit is contained in:
parent
4b64ebe623
commit
32ef77d9fd
@ -389,6 +389,14 @@ class OpenStackModule:
|
||||
if results and isinstance(results, dict):
|
||||
self.ansible.exit_json(**results)
|
||||
except self.sdk.exceptions.OpenStackCloudException as e:
|
||||
self.ansible.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
params = {
|
||||
'msg': str(e),
|
||||
'extra_data': {
|
||||
'data': e.extra_data,
|
||||
'details': e.details,
|
||||
'response': e.response.text
|
||||
}
|
||||
}
|
||||
self.ansible.fail_json(**params)
|
||||
# if we got to this place, modules didn't exit
|
||||
self.ansible.exit_json(**self.results)
|
||||
|
Loading…
Reference in New Issue
Block a user