mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Also catch mysql errors so we can give the error message back through json rather than tracebacking
This commit is contained in:
parent
0a745de765
commit
e11ea4b402
1 changed files with 2 additions and 4 deletions
|
@ -498,16 +498,14 @@ def main():
|
|||
if user_exists(cursor, user, host):
|
||||
try:
|
||||
changed = user_mod(cursor, user, host, password, priv, append_privs)
|
||||
except SQLParseError, e:
|
||||
except (SQLParseError, InvalidPrivsError, MySQLdb.Error), e:
|
||||
module.fail_json(msg=str(e))
|
||||
except InvalidPrivsError, e:
|
||||
module.mail_json(msg=str(e))
|
||||
else:
|
||||
if password is None:
|
||||
module.fail_json(msg="password parameter required when adding a user")
|
||||
try:
|
||||
changed = user_add(cursor, user, host, password, priv)
|
||||
except SQLParseError, e:
|
||||
except (SQLParseError, InvalidPrivsError, MySQLdb.Error), e:
|
||||
module.fail_json(msg=str(e))
|
||||
elif state == "absent":
|
||||
if user_exists(cursor, user, host):
|
||||
|
|
Loading…
Reference in a new issue