Catch more errors in case we're fed garbage through API calls
Don't hang or crash, that's bad.
Change-Id: I77114c20fe2431718eda8dbefde1c390fe8283d4
diff --git a/util.py b/util.py
index c110380..090e06e 100644
--- a/util.py
+++ b/util.py
@@ -124,6 +124,9 @@
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)
+ except TypeError as e:
+ logging.error('perform_db_query(%s) got error %s', command, e)
+ raise InputError("Invalid type in API call argument: %s" % e)
return ret
@@ -157,7 +160,10 @@
raise
except ValueError as e:
logging.error('perform_daemon_query(%s) got error %s', command, e)
- raise InputError("Invalid value in API call: %s" % e)
+ raise InputError("Invalid value in API call argument: %s" % e)
+ except TypeError as e:
+ logging.error('perform_daemon_query(%s) got error %s', command, e)
+ raise InputError("Invalid type in API call argument: %s" % e)
return ret
@@ -200,7 +206,10 @@
raise
except ValueError as e:
logging.error('perform_db_update(%s) got error %s', command, e)
- raise InputError("Invalid value in API call: %s" % e)
+ raise InputError("Invalid value in API call argument: %s" % e)
+ except TypeError as e:
+ logging.error('perform_db_update(%s) got error %s', command, e)
+ raise InputError("Invalid type in API call argument: %s" % e)
return ret
@@ -235,7 +244,10 @@
raise
except ValueError as e:
logging.error('perform_vlan_update(%s) got error %s', command, e)
- raise InputError("Invalid value in API call: %s" % e)
+ raise InputError("Invalid value in API call argument: %s" % e)
+ except TypeError as e:
+ logging.error('perform_vlan_update(%s) got error %s', command, e)
+ raise InputError("Invalid type in API call argument: %s" % e)
return ret