Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1029252]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found