Permalink
Browse files

Rescue and log HTTP errors

  • Loading branch information...
1 parent 7eec524 commit 5a0fcc84ba4b2f3c0c4c4af70e677a3cf416fced @alexrabarts committed Mar 17, 2009
Showing with 12 additions and 2 deletions.
  1. +6 −1 lib/term_extraction/yahoo.rb
  2. +6 −1 lib/term_extraction/zemanta.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
@@ -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

0 comments on commit 5a0fcc8

Please sign in to comment.