lib/http_crawler/client.rb in http_crawler-0.3.0.1 vs lib/http_crawler/client.rb in http_crawler-0.3.0.2

- old
+ new

@@ -230,24 +230,30 @@ def request(&block) raise "必须定义块" unless block_given? n = max_error_num begin block.call - rescue HTTP::TimeoutError - # 超时错误切换代理 - if self.update_proxy? - retry - else - raise error - end rescue => error - # 错误尝试次数 - if n <= 0 - raise error + + case error + when HTTP::TimeoutError + # 超时错误切换代理 + if self.update_proxy? + retry + else + raise error + end + else - n -= 1 - retry + # 错误尝试次数 + if n <= 0 + raise error + else + n -= 1 + retry + end end + end end end end