2014-12-12 07:34:03 -05:00
|
|
|
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
require File.join(dir, 'httparty')
|
|
|
|
|
|
|
|
# Take note of the "; 1" at the end of the following line. It's required only if
|
|
|
|
# running this in IRB, because IRB will try to inspect the variable named
|
|
|
|
# "request", triggering the exception.
|
|
|
|
request = HTTParty.get 'https://rubygems.org/api/v1/versions/doesnotexist.json' ; 1
|
|
|
|
|
|
|
|
# Check an exception due to parsing the response
|
|
|
|
# because HTTParty evaluate the response lazily
|
|
|
|
begin
|
|
|
|
request.inspect
|
|
|
|
# This would also suffice by forcing the request to be parsed:
|
|
|
|
# request.parsed_response
|
2014-12-12 09:15:54 -05:00
|
|
|
rescue => e
|
2014-12-12 07:34:03 -05:00
|
|
|
puts "Rescued #{e.inspect}"
|
2014-12-12 09:15:54 -05:00
|
|
|
end
|