문제

I wrote simple function which handles fetching of the url:

def tender_page_get url, agent
  sleep(rand(6)+2)
  begin
    return agent.get(url).parser
  rescue Errno::ETIMEDOUT, Timeout::Error, Net::HTTPNotFound
    EYE.debug "--winter sleep #{url}"
    puts "-x-#{url}"
    sleep(300)
    tender_page_get url, agent
  rescue => e
    puts "-x-#{url}"
    EYE.debug "--unknown exception"
    EYE.debug "#{url} #{e.inspect}"
  end
end

The problem is, even though I am catching Net::HTTPNotFound in my first rescue block, I still see in my log records like:

--unknown exception
{url} 404 => Net::HTTPNotFound

which means that this exception was caught by the second rescue block. What could be the reason for that?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top