[IMP] mail: improve displayed error when template rendering crashes
Currently when rendering a template crashes, error is not easy to understand as it is hidden in a generic message. Purpose of this commit is to improve this message to indicate why the template fails to build (only the first error encountered). Task 2085912 PR #38708
This commit is contained in:
committed by
Thibault Delavallée
parent
a23fe117bf
commit
2b4e172c6f
@@ -236,9 +236,9 @@ class MailTemplate(models.Model):
|
||||
variables['object'] = record
|
||||
try:
|
||||
render_result = template.render(variables)
|
||||
except Exception:
|
||||
_logger.info("Failed to render template %r using values %r" % (template, variables), exc_info=True)
|
||||
raise UserError(_("Failed to render template %r using values %r")% (template, variables))
|
||||
except Exception as e:
|
||||
_logger.info("Failed to render template : %s" % e, exc_info=True)
|
||||
raise UserError(_("Failed to render template : %s") % e)
|
||||
if render_result == u"False":
|
||||
render_result = u""
|
||||
results[res_id] = render_result
|
||||
|
||||
Reference in New Issue
Block a user