Raise detailed exception

This change allows to throw a detailed exception
in case if 'files' list has 'None' value:
"""
Exception occurred:
  File "/<<PKGBUILDDIR>>/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
This commit is contained in:
Ivan Udovichenko 2017-11-02 04:22:34 +03:00 committed by Akihiro Motoki
parent 839340cc6f
commit d16f750b36
1 changed files with 10 additions and 3 deletions

View File

@ -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