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

Merge pull request #8092 from ghjm/mysql-exceptions

Added exception handling to database creation and deletion. Fixes #8075.
This commit is contained in:
James Cammarata 2014-07-11 11:59:12 -05:00
commit 5e0d07c93e

View file

@ -319,7 +319,10 @@ def main():
changed = False
if db_exists(cursor, db):
if state == "absent":
changed = db_delete(cursor, db)
try:
changed = db_delete(cursor, db)
except Exception, e:
module.fail_json(msg="error deleting database: " + str(e))
elif state == "dump":
rc, stdout, stderr = db_dump(module, login_host, login_user,
login_password, db, target,
@ -340,7 +343,10 @@ def main():
module.exit_json(changed=True, db=db, msg=stdout)
else:
if state == "present":
changed = db_create(cursor, db, encoding, collation)
try:
changed = db_create(cursor, db, encoding, collation)
except Exception, e:
module.fail_json(msg="error creating database: " + str(e))
module.exit_json(changed=changed, db=db)