[pmg-devel] [PATCH pmg-api] better error handling for ldap connect

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 19 06:49:35 CET 2019


On 3/18/19 2:58 PM, Dominik Csapak wrote:
> even though we create the ldap connection with 'onerror' => 'die',
> it returns undef and sets $@ on error during connect, so we want to use
> that instead of $!
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PMG/LDAPCache.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/PMG/LDAPCache.pm b/PMG/LDAPCache.pm
> index 567b5ea..ca18ad6 100755
> --- a/PMG/LDAPCache.pm
> +++ b/PMG/LDAPCache.pm
> @@ -370,7 +370,7 @@ sub ldap_connect_and_bind {
>       my ($self) = @_;
>  
>       my $ldap = $self->ldap_connect() ||
> -	 die "Can't bind to ldap server '$self->{id}': $! $@\n";
> +	 die "Can't bind to ldap server '$self->{id}': " . ($@ // "unknown error") . "\n";

for a future patch: if one needs to do such constructs it could be a pointer
that it maybe better to transform a post-if to a "normal" one :-)

>  
>       my $mesg;
>  
> 




More information about the pmg-devel mailing list