From: Chris R. <chr...@us...> - 2003-05-20 14:58:53
|
Update of /cvsroot/perl-ldap/ldap/lib/Net/LDAP In directory sc8-pr-cvs1:/tmp/cvs-serv11835/lib/Net/LDAP Modified Files: Constant.pm Util.pm Log Message: Extended ldap_error_name, ldap_error_text and ldap_error_desc to take Message args Index: Constant.pm =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Constant.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Constant.pm 8 May 2003 12:53:08 -0000 1.7 +++ Constant.pm 20 May 2003 14:58:49 -0000 1.8 @@ -53,12 +53,12 @@ } # These subs are really in Net::LDAP::Util, but need to access <DATA> -# so its esier for them to be here. +# so its easier for them to be here. my @err2name; sub Net::LDAP::Util::ldap_error_name { - my $code = 0 + shift; + my $code = 0 + (ref($_[0]) ? $_[0]->code : $_[0]); unless (@err2name) { seek(DATA,0,0); @@ -76,7 +76,7 @@ sub Net::LDAP::Util::ldap_error_text { - my $code = 0 + shift; + my $code = 0 + (ref($_[0]) ? $_[0]->code : $_[0]); my $text; seek(DATA,0,0); Index: Util.pm =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Util.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Util.pm 8 May 2003 09:27:41 -0000 1.17 +++ Util.pm 20 May 2003 14:58:49 -0000 1.18 @@ -18,7 +18,7 @@ $mesg = $ldap->search( .... ); - die "Error ",ldap_error_name($mesg->code) if $mesg->code; + die "Error ",ldap_error_name($mesg) if $mesg->code; =head1 DESCRIPTION @@ -44,28 +44,33 @@ ); $VERSION = "0.10"; -=item ldap_error_name ( NUM ) +=item ldap_error_name ( ERR ) -Returns the name corresponding with the error number passed in. If the -error is not known the a string in the form C<"LDAP error code %d(0x%02X)"> -is returned. +Returns the name corresponding with ERR. ERR can either be an LDAP +error number, or a C<Net::LDAP::Message> object containing an error +code. If the error is not known the a string in the form C<"LDAP error +code %d(0x%02X)"> is returned. =cut # Defined in Constant.pm -=item ldap_error_text ( NUM ) +=item ldap_error_text ( ERR ) -Returns the text from the POD description for the given error. If the -error code given is unknown then C<undef> is returned. +Returns the text from the POD description for the given error. ERR can +either be an LDAP error code, or a C<Net::LDAP::Message> object +containing an LDAP error code. If the error code given is unknown then +C<undef> is returned. =cut # Defined in Constant.pm -=item ldap_error_desc ( NUM ) +=item ldap_error_desc ( ERR ) -Returns a short text description of the error. +Returns a short text description of the error. ERR can either be an +LDAP error code or a C<Net::LDAP::Message> object containing an LDAP +error code. =cut @@ -171,7 +176,7 @@ ); sub ldap_error_desc { - my $code = shift; + my $code = (ref($_[0]) ? $_[0]->code : $_[0]); $err2desc[$code] || sprintf("LDAP error code %d(0x%02X)",$code,$code); } |