You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sebastian Bazley <se...@apache.org> on 2016/02/03 18:55:52 UTC

[whimsy.git] [1/1] Commit 8b04981: Log the error with the host details

Commit 8b04981c99456e5a87d29c9a278106302fef16a5:
    Log the error with the host details


Branch: refs/heads/master
Author: Sebb <se...@apache.org>
Committer: Sebb <se...@apache.org>
Pusher: sebb <se...@apache.org>

------------------------------------------------------------
lib/whimsy/asf/ldap.rb                                       | +++++++++++ ---
------------------------------------------------------------
14 changes: 11 additions, 3 deletions.
------------------------------------------------------------


diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index ed0394c..6890304 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -123,10 +123,18 @@ def self.search_one(base, filter, attrs=nil)
     init_ldap unless defined? @ldap
     return [] unless @ldap
 
-    Wunderbar.info "ldapsearch -x -LLL -b #{base} -s one #{filter} " +
+    target = @ldap.instance_variable_get('@args').join(":") rescue '?'
+
+    Wunderbar.info "[#{target}] ldapsearch -x -LLL -b #{base} -s one #{filter} " +
       "#{[attrs].flatten.join(' ')}"
-    
-    result = @ldap.search2(base, ::LDAP::LDAP_SCOPE_ONELEVEL, filter, attrs)
+
+    begin
+      result = @ldap.search2(base, ::LDAP::LDAP_SCOPE_ONELEVEL, filter, attrs)
+    rescue Exception => re
+      Wunderbar.warn "[#{target}] => #{re.inspect} for ldapsearch -x -LLL -b #{base} -s one #{filter} " +
+        "#{[attrs].flatten.join(' ')}"
+      raise re
+    end
 
     result.map! {|hash| hash[attrs]} if String === attrs