Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rescue and log HTTP errors

  • Loading branch information...
commit 5a0fcc84ba4b2f3c0c4c4af70e677a3cf416fced 1 parent 7eec524
@alexrabarts authored
Showing with 12 additions and 2 deletions.
  1. +6 −1 lib/term_extraction/yahoo.rb
  2. +6 −1 lib/term_extraction/zemanta.rb
View
7 lib/term_extraction/yahoo.rb
@@ -43,7 +43,12 @@ def gateway
end
def remote_xml
- open(uri).read
+ begin
+ open(uri).read
+ rescue => e
+ $stderr.puts "Couldn't fetch from API: #{e.message}" if $VERBOSE
+ nil
+ end
end
end
end
View
7 lib/term_extraction/zemanta.rb
@@ -41,7 +41,12 @@ def gateway
end
def remote_xml
- Net::HTTP.post_form(uri, post_params).body
+ begin
+ Net::HTTP.post_form(uri, post_params).body
+ rescue => e
+ $stderr.puts "Couldn't fetch from API: #{e.message}" if $VERBOSE
+ nil
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.