lib/activeldap/base.rb in ruby-activeldap-debug-0.7.3 vs lib/activeldap/base.rb in ruby-activeldap-debug-0.7.4

- old
+ new

@@ -271,11 +271,11 @@ Timeout.alarm(@@config[:timeout]) do begin yield @@conn rescue => e # Raise an LDAP error instead of RuntimeError or whatever - @@logger.debug("Converting #{e} to useful exception") + @@logger.debug("Converting '#{e.inspect}' to useful exception") raise *LDAP::err2exception(@@conn.err) if @@conn.err != 0 # Else reraise @@logger.debug('Reraising') raise e end @@ -285,34 +285,18 @@ retry if try_reconnect and @@config[:retry_on_timeout] and Base.reconnect() message = e.message message = exc.message unless exc.nil? @@logger.error(message) raise TimeoutError, message - rescue RuntimeError => e + rescue LDAP::ServerDown, LDAP::ResultError, RuntimeError => e @@logger.error("#{e.class} exception occurred in connection block") @@logger.error("Exception message: #{e.message}") @@logger.error("Exception backtrace: #{e.backtrace}") @@logger.error(exc.message) unless exc.nil? retry if try_reconnect and Base.reconnect() raise exc unless exc.nil? return nil - rescue LDAP::ServerDown => e - @@logger.error("#{e.class} exception occurred in connection block") - @@logger.error("Exception message: #{e.message}") - @@logger.error("Exception backtrace: #{e.backtrace}") - @@logger.error(exc.message) unless exc.nil? - retry if try_reconnect and Base.reconnect() - raise exc unless exc.nil? - return nil - rescue LDAP::ResultError => e - @@logger.error("#{e.class} exception occurred in connection block") - @@logger.error("Exception message: #{e.message}") - @@logger.error("Exception backtrace: #{e.backtrace}") - @@logger.error(exc.message) unless exc.nil? - retry if try_reconnect and Base.reconnect() - raise exc unless exc.nil? - return nil rescue LDAP::UndefinedType => e @@logger.error("#{e.class} exception occurred in connection block") @@logger.error("Exception message: #{e.message}") @@logger.error("Exception backtrace: #{e.backtrace}") # Do not retry - not a connection error @@ -450,11 +434,11 @@ val = config # Or a hash if config.respond_to?(:has_key?) attr = config[:attribute] || dnattr() val = config[:value] || '*' - objects = config[:objects] || @@config[:return_objects] + objects = config[:objects] unless config[:objects].nil? end Base.connection(ConnectionError.new("Failed in #{self.class}#find(#{config.inspect})")) do |conn| # Get some attributes conn.search(base(), ldap_scope(), "(#{attr}=#{val})") do |m| @@ -492,10 +476,10 @@ objects = @@config[:return_objects] # Or a hash if config.respond_to?(:has_key?) val = config[:value] || '*' attr = config[:attribute] || dnattr() - objects = config[:objects] || @@config[:return_objects] + objects = config[:objects] unless config[:objects].nil? end matches = [] Base.connection(ConnectionError.new("Failed in #{self.class}#find_all(#{config.inspect})")) do |conn| # Get some attributes