aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/error_handlers_with_gettext_can_clobber___36____64__.mdwn
blob: 719c1ef2565c95ce20a1f4a8fdfc4e8a220a6b98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[[!template id=gitbranch branch=smcv/ready/careful-eval author="[[smcv]]"
  browse="http://git.pseudorandom.co.uk/smcv/ikiwiki.git/shortlog/refs/heads/ready/careful-eval"]]
[[!tag patch]]

As noted in the [[!cpan 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.

Fixed in my branch smcv/ready/careful-eval. Another possibility
for fixing this would be to depend on something like Try::Tiny,
which is already indirectly recommended by ikiwiki, because
[[!cpan RPC::XML]], [[!cpan XML::Feed]], etc., depend on it.
--[[smcv]]

[[fixed in 3.20140227|done]] --s