Skip Menu |

This queue is for tickets about the Try-Tiny CPAN distribution.

Report information
The Basics
Id: 77113
Status: rejected
Priority: 0/
Queue: Try-Tiny

People
Owner: Nobody in particular
Requestors: eric.roode.cpan [...] gmail.com
Cc: ribasushi [...] leporine.io
AdminCc:

Bug Information
Severity: Important
Broken in: 0.11
Fixed in: (no value)



Subject: Exception not available in $_ within a given/when construct
A catch{} block inside a when{} block does not see the thrown exception in $_. If the catch block code examines $_, it will find the given() expression. Apparently, given/when masks $_ somehow. Workaround: The exception can be found in $::_, within a given/when construct or not. Alternatively, the exception can be found by using the passed argument to the catch{} code block. The attached file demonstrates the problem, and the $::_ workaround.
Subject: catch_problem.pl
use feature 'switch', 'say'; use Try::Tiny; try { die 'Oh hell'; } catch { say qq{catch top-level', \$_ is "$_"}; }; given ('condition') { when ('condition') { try { die 'WTF'; } catch { say qq{catch in 'given', \$_ is "$_"}; say qq{catch in 'given', \$::_ is "$::_"}; say qq{catch in 'given', arg is "$_[0]"}; }; } } for ('condition') { try { die 'WTF'; } catch { say qq{catch in 'for', \$_ is "$_"}; say qq{catch in 'for', \$::_ is "$::_"}; }; }
This is a duplicate of #65603 and #67801. The problem is caused by a limitation of perl itself, and Try::Tiny can't do anything about it. This is already mentioned in the CAVEATS section of the documentation.
Subject: Re: [rt.cpan.org #77113] Exception not available in $_ within a given/when construct
Date: Thu, 10 May 2012 13:45:21 -0400
To: bug-Try-Tiny [...] rt.cpan.org
From: Eric Roode <eric.roode [...] gmail.com>
Whoops, I missed that. Thanks for the quick reply. Honestly, I kind of thought that it might be that sort of situation. At least I can work around the problem. -- Eric On Thu, May 10, 2012 at 1:32 PM, Jesse Luehrs via RT < bug-Try-Tiny@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=77113 > > > This is a duplicate of #65603 and #67801. The problem is caused by a > limitation of perl itself, and Try::Tiny can't do anything about it. > This is already mentioned in the CAVEATS section of the documentation. >
On Thu May 10 13:45:31 2012, eric.roode@gmail.com wrote: Show quoted text
> Whoops, I missed that. Thanks for the quick reply. Honestly, I kind of > thought that it might be that sort of situation. At least I can work > around the problem. >
Note - since 5.18 the situation is different. I un-todoified the test so we can get an alert when the behavior changes again: https://github.com/ribasushi/try-tiny/commit/aaf0d61f7a Cheers!