lib/awesome_bot/statuses.rb in awesome_bot-1.2.1 vs lib/awesome_bot/statuses.rb in awesome_bot-1.3.0
- old
+ new
@@ -1,10 +1,12 @@
# Get link status
module AwesomeBot
require 'faraday'
require 'parallel'
+ STATUS_ERROR = -1
+
class << self
def net_head_status(url)
Faraday.head(url).status
end
@@ -20,14 +22,15 @@
statuses = []
Parallel.each(links, in_threads: threads) do |u|
begin
status = net_status u, head
rescue => e
- status = e
+ status = STATUS_ERROR
+ error = e
end
yield status, u
- statuses.push('url' => u, 'status' => status)
+ statuses.push('url' => u, 'status' => status, 'error' => error)
end # Parallel
statuses
end
end # class