Mercurial > piecrust2
diff piecrust/rendering.py @ 153:1c3d229158ba
Make a nice error message when a layout hasn't been found.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 04 Dec 2014 12:49:53 -0800 |
parents | 28444014ce7d |
children | 1187739e5a19 |
line wrap: on
line diff
--- a/piecrust/rendering.py Thu Dec 04 12:49:35 2014 -0800 +++ b/piecrust/rendering.py Thu Dec 04 12:49:53 2014 -0800 @@ -4,7 +4,7 @@ from piecrust.data.builder import (DataBuildingContext, build_page_data, build_layout_data) from piecrust.sources.base import PageSource -from piecrust.templating.base import TemplatingError +from piecrust.templating.base import TemplateNotFoundError, TemplatingError from piecrust.uriutil import get_slug @@ -205,7 +205,12 @@ engine = get_template_engine(page.app, engine_name) if engine is None: raise PageRenderingError("No such template engine: %s" % engine_name) - output = engine.renderFile(full_names, layout_data) + try: + output = engine.renderFile(full_names, layout_data) + except TemplateNotFoundError as ex: + msg = "Can't find template for page: %s\n" % page.path + msg += "Looked for: %s" % ', '.join(full_names) + raise Exception(msg) from ex return output