Skip to content

Commit

Permalink
We should handle success too, and not just failure
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Apr 22, 2011
1 parent 37b0388 commit 284dd9b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/gist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ def write(files, private_gist = false)
req = Net::HTTP::Post.new(url.path)
req.form_data = data(files, private_gist)

response = http.start {|h| h.request(req) }
begin
response.value
rescue => error
puts "Creating gist failed: #{error}"
exit(false)
else
response = http.start{|h| h.request(req) }
case response
when Net::HTTPRedirection
response['Location']
else
puts "Creating gist failed: #{response.code} #{response.message}"
exit(false)
end
end

Expand Down

0 comments on commit 284dd9b

Please sign in to comment.