On Thursday, August 22, 2002, at 06:17 AM, Ronald J Kimball wrote: > That syntax is not supported in perl5.005; the arrow before the > subroutine > arguments was required until perl5.6.
Ah, yes, I actually was wondering about that.
> It might also be good to make sure $attr->{HandleError} is actually a
> code
> reference before dereferencing it.
>
> $attr->{HandleError}->($msg, $drh, $dbh)
> if (ref $attr->{HandleError} &&
> UNIVERSAL::isa($attr->{HandleError}, 'CODE'));
Good idea. I think that the C<ref $attr->{HandleError}> is unnecessary,
though, as UNIVERSAL::isa() will happily evaluate any value. Unless
that's not true for pre perl5.6.
Here's my alternate patch:
--- DBI.pm.org Wed Aug 21 21:09:27 2002
+++ DBI.pm Thu Aug 22 07:10:29 2002
@@ -503,7 +513,9 @@
unless ($dbh = $drh->$connect_meth($dsn, $user, $pass, $attr)) {
my $msg = "$class->connect($dsn) failed: ".$drh->errstr;
if (%attr) {
- # XXX add $attr{HandleError} logic here?
+ # XXX add $attr{HandleError} logic here? Yes!
+ $attr->{HandleError}($msg, $drh, $dbh)
+ if UNIVERSAL::isa($attr->{HandleError}, 'CODE');
Carp::croak($msg) if $attr->{RaiseError};
Carp::carp ($msg) if $attr->{PrintError};
}
And I attach a new version of the bigger patch that changes all
instances of croak() in connect() to use HandleError if it's present.
Regards,
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: [EMAIL PROTECTED]
DBI.patch
Description: Binary data
