From d16f750b36db3f220bca63e8fab509074e49ed6d Mon Sep 17 00:00:00 2001 From: Ivan Udovichenko Date: Thu, 2 Nov 2017 04:22:34 +0300 Subject: [PATCH] Raise detailed exception This change allows to throw a detailed exception in case if 'files' list has 'None' value: """ Exception occurred: File "/<>/openstack_dashboard/utils/\ settings.py", line 263, in get_xstatic_dirs for file in files: TypeError: 'NoneType' object is not iterable """ Closes-Bug: #1732567 Change-Id: Iaf6282819c26c12ca24d19ef7dee00a5c8586418 --- openstack_dashboard/utils/settings.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py index 8a760deeeb..d7b6e26fba 100755 --- a/openstack_dashboard/utils/settings.py +++ b/openstack_dashboard/utils/settings.py @@ -265,9 +265,16 @@ def get_xstatic_dirs(XSTATIC_MODULES, HORIZON_CONFIG): files = [file for file in files if file.endswith('.js')] # add to the list of files to link in the HTML - for file in files: - file = 'horizon/lib/' + module.NAME + '/' + file - HORIZON_CONFIG['xstatic_lib_files'].append(file) + try: + for file in files: + file = 'horizon/lib/' + module.NAME + '/' + file + HORIZON_CONFIG['xstatic_lib_files'].append(file) + except TypeError: + raise Exception( + '%s: Nothing to include because files to include are not ' + 'defined (i.e., None) in BASE_XSTATIC_MODULES list and ' + 'a corresponding XStatic module does not define MAIN list.' + % module_name) return STATICFILES_DIRS