Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
go ahead... be a heretic
 
PerlMonks  

Re^2: A couple questions about object oriented Perl programming: inheritance and error handling (eval $@ truth)

by Anonymous Monk
on Apr 18, 2013 at 04:13 UTC ( #1029252=note: print w/ replies, xml ) Need Help??


in reply to Re: A couple questions about object oriented Perl programming: inheritance and error handling
in thread A couple questions about object oriented Perl programming: inheritance and error handling

$@ might not be a true value :) or other things, see Try::Tiny and Devel::EvalError for a description of the possible issue

eval { execeptionalWithoutReturnValue(); 1; } or do { my $exception = $@; ... };

Or

use Try::Tiny;
try {
  execeptionalWithoutReturnValue();
} catch {
  warn "caught error: $_"; # not $@
};

Or

use Devel::EvalError();
my $ee = Deval::EvalError->new();
$ee->ExpectOne(
    eval {
        execeptionalWithoutReturnValue();
        1;
    }
);
if( $ee->Failed() ) {    # if ( ! $ee->Succeeded() )
    ... $ee->Reason() ...;
}


Comment on Re^2: A couple questions about object oriented Perl programming: inheritance and error handling (eval $@ truth)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029252]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (15)
As of 2014-04-18 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls