Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

properly handle errors #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/relevance/tarantula/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ def initialize(link, crawler, referrer)
end

def crawl
response = crawler.follow(method, href)
log "Response #{response.code} for #{self}"
crawler.handle_link_results(self, make_result(response))
response = nil
begin
response = crawler.follow(method, href)
log "Response #{response.code} for #{self}"
rescue
ensure
crawler.handle_link_results(self, make_result(response))
end
end

def make_result(response)
Expand Down Expand Up @@ -91,7 +96,7 @@ def hash
end

def to_s
"<Relevance::Tarantula::Link href=#{href}, method=#{method}>"
"<Relevance::Tarantula::Link href=#{href}, method=#{method}, referrer=#{referrer}>"
end

end
Expand Down