def fetch_something_from_some_api(uri) http = Net::HTTP.new(uri.host, uri.port) http.read_timeout = timeout response = http.start { http.request(Net::HTTP::Get.new("#{uri.path}?#{uri.query}")) } response.is_a?(Net::HTTPSuccess) ? do_something_with(response.body) : nil rescue Timeout::Error logger.warn("Timeout accessing #{uri}: #{$!}") nil rescue logger.warn("Error accessing #{uri}: #{$!}") nil end