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

Dominik Csapak d.csapak at proxmox.com
Mon Mar 18 14:58:32 CET 2019


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";
 
      my $mesg;
 
-- 
2.11.0




More information about the pmg-devel mailing list