From ad07734c6deba73eaa46e6c891f05ad56891d149 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Fri, 27 Jun 2014 17:44:07 -0600 Subject: [PATCH] Exception handling in mysql module --- salt/modules/mysql.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 2a82d6f1fc..90bbaf1167 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -1572,9 +1572,13 @@ def grant_exists(grant, salt '*' mysql.grant_exists \ 'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost' ''' - target = __grant_generate( - grant, database, user, host, grant_option, escape - ) + try: + target = __grant_generate( + grant, database, user, host, grant_option, escape + ) + except Exception: + log.error('Error during grant generation.') + return False grants = user_grants(user, host, **connection_args) @@ -1636,7 +1640,11 @@ def grant_add(grant, # Avoid spaces problems grant = grant.strip() - qry = __grant_generate(grant, database, user, host, grant_option, escape, ssl_option) + try: + qry = __grant_generate(grant, database, user, host, grant_option, escape, ssl_option) + except Exception: + log.error('Error during grant generation') + return False try: _execute(cur, qry['qry'], qry['args']) except (MySQLdb.OperationalError, MySQLdb.ProgrammingError) as exc: