From 6e34beb89a98aa58ec61bd4c89ae9a3dabd70f8f Mon Sep 17 00:00:00 2001 From: Jin Li Date: Wed, 11 Jan 2017 15:53:28 -0800 Subject: [PATCH] Catch the right type of exceptions The function get_table_class() catches the ValueError exception. Change it to catch TypeError and KeyError because these two are the only possible exceptions threw inside the function. test case of this change is covered in: https://review.openstack.org/#/c/419210/ Change-Id: I4b28d9bcee1dcff9f91b3535ea8dc07750e28abb Closes-Bug: #1655784 --- gluon/particleGenerator/DataBaseModelGenerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/particleGenerator/DataBaseModelGenerator.py b/gluon/particleGenerator/DataBaseModelGenerator.py index cab9b87..9abea86 100644 --- a/gluon/particleGenerator/DataBaseModelGenerator.py +++ b/gluon/particleGenerator/DataBaseModelGenerator.py @@ -39,7 +39,7 @@ class DataBaseModelProcessor(object): def get_table_class(self, api_name, table_name): try: return self.db_models.get(api_name)[table_name] - except ValueError: + except(TypeError, KeyError): raise Exception('Unknown table name %s' % table_name) def build_sqla_models(self, api_name, base=None):