in reply to Re^3: Try::Tiny catch block with $_ eq ''
in thread Try::Tiny catch block with $_ eq ''
That's not the main eval gotcha that Try::Tiny seeks to solve. Amongst the things mentioned in Try::Tiny's documentation are:
- It is possible to throw an exception which is considered false in a boolean context, thus breaking if ($@). Try::Tiny isn't fooled by that.
- If a DESTROY method calls eval then an object used within your eval could potentially clobber $@. Try::Tiny creates a copy of $@ that is safe, and passes it as a parameter to the catch block.
These errors are fairly rare in practice, but extremely difficult to figure out when they do happen. People who have been burned by them in the past tend to appreciate Try::Tiny quite a lot.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Try::Tiny catch block with $_ eq ''
by vsespb (Chaplain) on May 17, 2013 at 12:38 UTC |
In Section
Seekers of Perl Wisdom