summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-04-23 14:07:28 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-04-23 14:07:28 -0400
commit748aa7af777caaa32ac5ab56e707509b3739b49e (patch)
treee5ab8791c45420d114efee9df68cee2ef8181478 /IkiWiki.pm
parent2c74f09bb870c717669f273ba7d4aa1637dcccf1 (diff)
pagespec error/failure distinction and error display by inline
* Add IkiWiki::ErrorReason objects, and modify pagespecs to return them in cases where they fail to match due to a configuration or syntax error. * inline: Display a handy error message if the inline cannot display any pages due to such an error. This is perhaps somewhat incomplete, as other users of pagespecs do not display the error, and will eventually need similar modifications to inline. I should probably factor out a pagespec_match_all function and make it throw ErrorReasons.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm14
1 files changed, 9 insertions, 5 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 2eca82e4d..fca8da874 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1800,7 +1800,7 @@ sub pagespec_translate ($) {
$code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \@_)";
}
else {
- $code.="IkiWiki::FailReason->new(".safequote(qq{unknown function in pagespec "$word"}).")";
+ $code.="IkiWiki::ErrorReason->new(".safequote(qq{unknown function in pagespec "$word"}).")";
}
}
else {
@@ -1827,7 +1827,7 @@ sub pagespec_match ($$;@) {
}
my $sub=pagespec_translate($spec);
- return IkiWiki::FailReason->new("syntax error in pagespec \"$spec\"")
+ return IkiWiki::ErrorReason->new("syntax error in pagespec \"$spec\"")
if $@ || ! defined $sub;
return $sub->($page, @params);
}
@@ -1861,6 +1861,10 @@ sub new {
return bless \$value, $class;
}
+package IkiWiki::ErrorReason;
+
+our @ISA = 'IkiWiki::FailReason';
+
package IkiWiki::SuccessReason;
use overload (
@@ -2021,7 +2025,7 @@ sub match_user ($$;@) {
my %params=@_;
if (! exists $params{user}) {
- return IkiWiki::FailReason->new("no user specified");
+ return IkiWiki::ErrorReason->new("no user specified");
}
if (defined $params{user} && lc $params{user} eq lc $user) {
@@ -2041,7 +2045,7 @@ sub match_admin ($$;@) {
my %params=@_;
if (! exists $params{user}) {
- return IkiWiki::FailReason->new("no user specified");
+ return IkiWiki::ErrorReason->new("no user specified");
}
if (defined $params{user} && IkiWiki::is_admin($params{user})) {
@@ -2061,7 +2065,7 @@ sub match_ip ($$;@) {
my %params=@_;
if (! exists $params{ip}) {
- return IkiWiki::FailReason->new("no IP specified");
+ return IkiWiki::ErrorReason->new("no IP specified");
}
if (defined $params{ip} && lc $params{ip} eq lc $ip) {