Guard against network issues
This commit is contained in:
@@ -9,6 +9,8 @@ module Adamantium
|
|||||||
|
|
||||||
def call(imdb_id:)
|
def call(imdb_id:)
|
||||||
@client.find_by_id(imdb_id)
|
@client.find_by_id(imdb_id)
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -11,7 +11,7 @@ module Adamantium
|
|||||||
end
|
end
|
||||||
|
|
||||||
def call(post:)
|
def call(post:)
|
||||||
uri = URI('https://api.raindrop.io/rest/v1/raindrop')
|
uri = URI("https://api.raindrop.io/rest/v1/raindrop")
|
||||||
|
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
http.use_ssl = true
|
http.use_ssl = true
|
||||||
@@ -21,14 +21,20 @@ module Adamantium
|
|||||||
"link" => post[:url]
|
"link" => post[:url]
|
||||||
}
|
}
|
||||||
body = JSON.dump(dict)
|
body = JSON.dump(dict)
|
||||||
req = Net::HTTP::Post.new(uri)
|
req = Net::HTTP::Post.new(uri)
|
||||||
req.add_field "Authorization", api_key
|
req.add_field "Authorization", api_key
|
||||||
req.add_field "Content-Type", "application/json; charset=utf-8"
|
req.add_field "Content-Type", "application/json; charset=utf-8"
|
||||||
req.body = body
|
req.body = body
|
||||||
|
|
||||||
response = http.request(req)
|
response = nil
|
||||||
|
|
||||||
if response.code.to_s == "200"
|
begin
|
||||||
|
response = http.request(req)
|
||||||
|
rescue
|
||||||
|
# NOOP
|
||||||
|
end
|
||||||
|
|
||||||
|
if response && response.code.to_s == "200"
|
||||||
Success()
|
Success()
|
||||||
else
|
else
|
||||||
Failure(:failed_to_post_to_raindrop)
|
Failure(:failed_to_post_to_raindrop)
|
||||||
|
Reference in New Issue
Block a user