add human-readable error when unknown pagespec function is called
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 20 Jan 2009 21:30:59 +0000 (16:30 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 20 Jan 2009 21:35:18 +0000 (16:35 -0500)
It used to replace unknown functions with "0" when translating a pagespec.
Instead, replace it with a FailReason object. This way, the pagespec will
still evaluate as before (possibly successfully if other terminals exist),
but a human-readable error will be shown if the result is displayed.

Also, an empty pagespec used to be replaced with "0", to avoid a eval
error. Also use a FailReason here.

IkiWiki.pm

index ca483a111693291adab7efbc720b2f8bdeda94c3..4d8415ffd6c67ef47d1e812e65596fd4550f6d0c 100644 (file)
@@ -1729,7 +1729,7 @@ sub pagespec_translate ($) {
                                $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \@_)";
                        }
                        else {
-                               $code.=' 0';
+                               $code.="IkiWiki::FailReason->new(".safequote(qq{unknown function in pagespec "$word"}).")";
                        }
                }
                else {
@@ -1738,7 +1738,7 @@ sub pagespec_translate ($) {
        }
 
        if (! length $code) {
-               $code=0;
+               $code="IkiWiki::FailReason->new('empty pagespec')";
        }
 
        no warnings;