in reply to Re: Best Practices for Exception Handling
in thread Best Practices for Exception Handling
my method is similar, but different...
## let's say bar is a method in foo sub bar { my( $self, @args )= @_; eval { $self->method( @args ) }; $@ and $self->raise_error( @_ ) and return undef; } ## called like: my $foo= foo->new(); my $result= $foo->bar( @args ) or warn $foo->Error();
the method sets an error and returns undef, allowing the caller to deal with the error as it sees fit. of course, you might want to handle a method that can return 0 by using defined
~Particle *accelerates*
|
---|
Replies are listed 'Best First'. | |
---|---|
Re*Re^2: Best Practices for Exception Handling
by bart (Canon) on Jan 29, 2003 at 09:40 UTC | |
Re^3: Best Practices for Exception Handling
by theguvnor (Chaplain) on Jan 29, 2003 at 02:06 UTC | |
Re: Re^2: Best Practices for Exception Handling
by demerphq (Chancellor) on Jan 29, 2003 at 17:06 UTC |
In Section
Seekers of Perl Wisdom