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.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 6da281999..66ae86809 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1769,12 +1769,14 @@ sub template_depends ($$;@) { my $page=shift; my ($filename, $tpage, $untrusted)=template_file($name); + if (! defined $filename) { + error(sprintf(gettext("template %s not found"), $name)) + } + if (defined $page && defined $tpage) { add_depends($page, $tpage); } - - return unless defined $filename; - + my @opts=( filter => sub { my $text_ref = shift; -- cgit v1.2.3