From e22b18aabcb46e3c0eafeb466b51bb3eb18cf1e1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Sep 2010 15:47:14 -0400 Subject: template_depends: throw nice error message when template cannot be found plovs reported a crash when templates were not installed properly, with a non-useful error about the template object not being defined. I've audited all uses of template_depends(), and template(), and it makes sense for them to throw an error if the template cannot be found. All code with a user-supplied template catches errors already, to handle template parse failures. It did not make sense for template_file to throw errors, as some code uses it to probe if a template file is available. --- IkiWiki/Plugin/edittemplate.pm | 3 --- IkiWiki/Plugin/inline.pm | 5 +---- IkiWiki/Plugin/template.pm | 7 ++----- 3 files changed, 3 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 4f07866e4..576c94be4 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -132,9 +132,6 @@ sub filltemplate ($$) { # up a template that doesn't work. return "[[!pagetemplate ".gettext("failed to process template:")." $@]]"; } - if (! defined $template) { - return; - } $template->param(name => $page); diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 715a3d652..c00aed299 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -336,10 +336,7 @@ sub preprocess_inline (@) { blind_cache => 1); }; if ($@) { - error gettext("failed to process template:")." $@"; - } - if (! $template) { - error sprintf(gettext("template %s not found"), $params{template}.".tmpl"); + error sprintf(gettext("failed to process template %s"), $params{template}.".tmpl").": $@"; } } my $needcontent=$raw || (!($archive && $quick) && $template->query(name => 'content')); diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index db26bfe31..3df06e652 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -41,12 +41,9 @@ sub preprocess (@) { blind_cache => 1); }; if ($@) { - error gettext("failed to process template:")." $@"; - } - if (! $template) { - error sprintf(gettext("%s not found"), + error sprintf(gettext("failed to process template %s"), htmllink($params{page}, $params{destpage}, - "/templates/$params{id}")) + "/templates/$params{id}"))." $@"; } $params{basename}=IkiWiki::basename($params{page}); -- cgit v1.2.3