diff options
author | Simon McVittie <smcv@debian.org> | 2014-02-21 17:06:36 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-02-21 17:06:36 +0000 |
commit | bb359796b80d2e8bd36f6c8eafe9510874184e32 (patch) | |
tree | fd25147af7e94441d0189810734a5f59617110ca /IkiWiki/Plugin/aggregate.pm | |
parent | be3483fe9be559a62dd88577b3a374d55b7262f3 (diff) | |
download | ikiwiki-bb359796b80d2e8bd36f6c8eafe9510874184e32.tar ikiwiki-bb359796b80d2e8bd36f6c8eafe9510874184e32.tar.gz |
protect $@ whenever a block using $@ is non-trivial
As noted in the Try::Tiny man page, eval/$@ can be quite awkward in
corner cases, because $@ has the same properties and problems as C's
errno. While writing a regression test for definetemplate
in which it couldn't find an appropriate template, I received
<span class="error">Error: failed to process template
<span class="createlink">deftmpl</span> </span>
instead of the intended
<span class="error">Error: failed to process template
<span class="createlink">deftmpl</span> template deftmpl not
found</span>
which turned out to be because the "catch"-analogous block called
gettext before it used $@, and gettext can call define_gettext,
which uses eval.
This commit alters all current "catch"-like blocks that use $@, except
those that just do trivial things with $@ (string interpolation, string
concatenation) and call a function (die, error, print, etc.)
Diffstat (limited to 'IkiWiki/Plugin/aggregate.pm')
-rw-r--r-- | IkiWiki/Plugin/aggregate.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 28c445913..fbf88c627 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -553,7 +553,9 @@ sub aggregate (@) { }; } if ($@) { - $feed->{message}=gettext("feed crashed XML::Feed!")." ($@)"; + # gettext can clobber $@ + my $error = $@; + $feed->{message}=gettext("feed crashed XML::Feed!")." ($error)"; $feed->{error}=1; debug($feed->{message}); next; @@ -675,7 +677,9 @@ sub write_page ($$$$$) { $template=template($feed->{template}, blind_cache => 1); }; if ($@) { - print STDERR gettext("failed to process template:")." $@"; + # gettext can clobber $@ + my $error = $@; + print STDERR gettext("failed to process template:")." $error"; return; } $template->param(title => $params{title}) |