diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2015-10-09 16:51:28 +0100 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2015-10-09 16:51:28 +0100 |
commit | 978cb9f52954f03c4ce78c2171858d3f6963a4ac (patch) | |
tree | a5d1138fc81aa5e85652116d6b453aed477e74c0 /util.py | |
parent | 5f42a68a8ef9cfee4ef320b02d420803cbb44bcb (diff) |
More robust error handling and logging
Catch and log InputError()
Catch and log ValueError() and report back to the API user
Change-Id: I1d7414baa4a84106439c37ad36be3578356a3371
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -103,11 +103,12 @@ class VlanUtil: else: raise InputError("Unknown db_query command \"%s\"" % command) - except InputError: + except InputError as e: + logging.error('perform_db_query(%s) got error %s', command, e) raise - -# except: -# raise InputError("Invalid input in query") + except ValueError as e: + logging.error('perform_db_query(%s) got error %s', command, e) + raise InputError("Invalid value in API call argument: %s" % e) return ret @@ -135,11 +136,12 @@ class VlanUtil: else: raise InputError("Unknown daemon_query command \"%s\"" % command) - except InputError: + except InputError as e: + logging.error('perform_daemon_query(%s) got error %s', command, e) raise - -# except: -# raise InputError("Invalid input in query") + except ValueError as e: + logging.error('perform_daemon_query(%s) got error %s', command, e) + raise InputError("Invalid value in API call: %s" % e) return ret @@ -177,11 +179,12 @@ class VlanUtil: else: raise InputError("Unknown db_update command \"%s\"" % command) - except InputError: + except InputError as e: + logging.error('perform_db_update(%s) got error %s', command, e) raise - -# except: -# raise InputError("Invalid input in query") + except ValueError as e: + logging.error('perform_db_update(%s) got error %s', command, e) + raise InputError("Invalid value in API call: %s" % e) return ret @@ -212,11 +215,11 @@ class VlanUtil: raise InputError("Unknown query command \"%s\"" % command) except InputError as e: - logging.debug('got error %s', e) + logging.error('perform_vlan_update(%s) got error %s', command, e) raise - -# except: -# raise InputError("Invalid input in query") + except ValueError as e: + logging.error('perform_vlan_update(%s) got error %s', command, e) + raise InputError("Invalid value in API call: %s" % e) return ret |