[bop-devel] quick fix for LinkPoint.pm

Phil Lobbes phil at perkpartners.com
Sat Jan 20 13:17:44 PST 2007


Just from a quick look at the B::OP code, the only method in
LinkPoint.pm that potentially croak is submit().  Also, LinkPoint.pm
uses the Perl module provided by linkpoint (lpperl.pm) which itself has
a few places where it will die().

In this case I'd certainly recommend wrapping the submit call with
something like:

  eval { $tx->submit };
  if ($@) {
  ...
  }

Based on my experience I would recommend this for any calls to submit.
This use of die() and croak() is not unique to just LinkPoint.pm, but
infact is typical of a number of Business::OnlinePayment backends and
the modules provided by the payment services that the backends rely on.

In the place that LinkPoint.pm uses croak() {ERROR} status (which is
supposed to be provided by lpperl.pm) would be set.  The information in
$@ is all that you have to work with.  In theory perhaps LinkPoint.pm
could just pass anything that isn't recognized on through to lpperl.pm
and let it do it's thing but that might also just die() (just a guess).

There's certainly room for improvement.  For the longer term we may want
to consider using something like Exception::Class (see also
http://www.perl.com/pub/a/2002/11/14/exception.html).  You'll notice
that eval{} is still an integral part of Exception::Class.  But for now
we just have eval and $@.

Ideas on how to improve this are certainly welcome!

Phil

Jo Rhett <jrhett at netconsonance.com> wrote:

> Jo Rhett wrote:
> > As to your suggestion -- Eval the invocation of every BOP function
> > call?  Perhaps I'm being old fashioned, but isn't this creating lots
> > of extra code for no particular gain that I can see?  And doesn't it
> > prevent the return of useful data?  For instance, I can't check
> > {ERROR} status after exiting the eval block, can I?
> 
> FYI, this is a request that if I am misunderstanding the
> implementation, please educate me.
> 
> -- 
> Jo Rhett
> Network/Software Engineer
> Net Consonance
> _______________________________________________
> bop-devel mailing list
> bop-devel at 420.am
> http://420.am/cgi-bin/mailman/listinfo/bop-devel


More information about the bop-devel mailing list