Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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?
[1nickt]: TCLion are you parsing the dates with DateTime or another tool?
[1nickt]: I note DateTime::Format:: Flexible, announced immediately below this box in the CPAN feed
[Corion]: 1nickt: That one sounds sensible as it will tell you when it found an error
[1nickt]: Throws on error, I believe
[1nickt]: But should handle month as number or word
[TCLion]: I am breaking down the line and putting the date in the correct order during output
[TCLion]: at least that's the plan

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (17)
As of 2017-03-23 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (288 votes). Check out past polls.