Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re^2: Best Practices for Exception Handling

by demerphq (Chancellor)
on Jan 29, 2003 at 17:06 UTC ( #231016=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Best Practices for Exception Handling
in thread Best Practices for Exception Handling

Personally I think the following little trick/modification makes for cleaner code... (and I think that raise_error makes more sense if it contains the error message returned...)

sub bar { my( $self, @args )= @_; eval { $self->method( @args ); 1} or $self->raise_error( $@, @_ ) and return undef; }
If you can contrive to make raise_error() return undef you can make it even cleaner
sub bar { my( $self, @args )= @_; eval { $self->method( @args ); 1} or return $self->raise_error( $@, @_ ); }

--- demerphq
my friends call me, usually because I'm late....


Comment on Re: Re^2: Best Practices for Exception Handling
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-09-18 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (111 votes), past polls