Commit ecdd92a8 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(configd) improve error reporting

(cherry picked from commit 88ebf762)
parent 47c77e97
......@@ -487,9 +487,10 @@ class Action(object):
return ph_inline_actions.execute(self, inline_act_parameters)
except:
syslog.syslog(syslog.LOG_ERR, '[%s] Inline action failed at %s' % (message_uuid,
traceback.format_exc()))
except Exception as inline_exception:
syslog.syslog(syslog.LOG_ERR, '[%s] Inline action failed with %s at %s' % (message_uuid,
inline_exception,
traceback.format_exc()))
return 'Execute error'
return 'Unknown action type'
......@@ -232,7 +232,12 @@ class Template(object):
result_filenames[new_filename][key] = target_filters[target_filter][key]
template_filename = '%s/%s'%(module_name.replace('.', '/'), src_template)
j2_page = self._j2_env.get_template(template_filename)
# parse template, make sure issues can be traced back to their origin
try:
j2_page = self._j2_env.get_template(template_filename)
except jinja2.exceptions.TemplateSyntaxError as templExc:
raise Exception("%s %s %s" % (module_name, template_filename, templExc))
for filename in result_filenames.keys():
if not (filename.find('[') != -1 and filename.find(']') != -1):
# copy config data
......@@ -245,7 +250,11 @@ class Template(object):
# make sure we're only rendering output once
if filename not in result:
# render page and write to disc
content = j2_page.render(cnf_data)
try:
content = j2_page.render(cnf_data)
except Exception as render_exception:
# push exception with context if anything fails
raise Exception("%s %s %s" % (module_name, template_filename, render_exception))
# prefix filename with defined root directory
filename = ('%s/%s' % (self._target_root_directory, filename)).replace('//', '/')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment