1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Return exception as string

Pyodbc returns exception as Python Exception class,
typecast as string for fail_json.

Partially fixes: #25010

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-06-10 23:00:22 +05:30 committed by Brian Coca
parent da6f6d27e8
commit 077a2df1d6
5 changed files with 10 additions and 5 deletions

View file

@ -89,6 +89,7 @@ else:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
class NotSupportedError(Exception):
@ -198,7 +199,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg=e)
module.fail_json(msg=to_native(e))
module.exit_json(changed=changed, parameter=parameter_name, ansible_facts={'vertica_configuration': configuration_facts})

View file

@ -81,6 +81,7 @@ else:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
class NotSupportedError(Exception):
@ -278,7 +279,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg=e)
module.fail_json(msg=to_native(e))
if __name__ == '__main__':

View file

@ -100,6 +100,7 @@ else:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
class NotSupportedError(Exception):
@ -248,7 +249,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg=e)
module.fail_json(msg=to_native(e))
module.exit_json(changed=changed, role=role, ansible_facts={'vertica_roles': role_facts})

View file

@ -124,6 +124,7 @@ else:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
class NotSupportedError(Exception):
@ -323,7 +324,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg=e)
module.fail_json(msg=to_native(e))
module.exit_json(changed=changed, schema=schema, ansible_facts={'vertica_schemas': schema_facts})

View file

@ -137,6 +137,7 @@ else:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
class NotSupportedError(Exception):
@ -393,7 +394,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg=e)
module.fail_json(msg=to_native(e))
module.exit_json(changed=changed, user=user, ansible_facts={'vertica_users': user_facts})