Browse Source

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
changes/06/419206/2
Jin Li 5 years ago
parent
commit
6e34beb89a
  1. 2
      gluon/particleGenerator/DataBaseModelGenerator.py

2
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):

Loading…
Cancel
Save