in reply to Re: Question on "Effective Perl Programming" (;1 > $@)
in thread Question on "Effective Perl Programming"
Ouch! That will eat any useful exception you want to throw too. Consider:
package EvalEater; sub new { bless {} } sub DESTROY { eval { sleep 1 if 0 } } package main; use Test::More 'tests' => 2; use Exception::Class ( 'Bomb' ); my $okay = eval { my $ee = EvalEater->new(); Bomb->throw( error => 'Ouch!' ); 1; }; ok( ! $@, "Eval appears to succeed: $@" ); ok( ! defined $okay, "Eval failed silently" );
I see the local $@ will fix the EvalEater, but is there a way to rescue the exception if I can't change EvalEater?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question on "Effective Perl Programming" (intervene)
by tye (Sage) on Sep 06, 2007 at 14:43 UTC | |
by Anonymous Monk on Sep 07, 2007 at 13:11 UTC | |
by girarde (Hermit) on Sep 08, 2007 at 21:03 UTC | |
by runrig (Abbot) on Sep 08, 2007 at 21:22 UTC | |
by kyle (Abbot) on Sep 08, 2007 at 21:39 UTC | |
by tye (Sage) on Sep 08, 2007 at 23:03 UTC |