{"comment":{"created_at":"2011-10-25T14:49:55Z","body":"I understand your point about the 404 not being valid JSON, but it doesn't seem to be possible to trap this exception. How do you suggest we use HTTParty to query a site that does this?\r\n\r\nBy the way, Gravatar does the same thing: http://en.gravatar.com/d87e5be65260478fa1a3c0d67ac8fb45.json\r\n","updated_at":"2011-10-25T14:49:55Z","url":"https://api.github.com/repos/jnunemaker/httparty/issues/comments/2518085","id":2518085,"user":{"avatar_url":"https://secure.gravatar.com/avatar/13ff077619271fe2f1222545a6a7e69c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"13ff077619271fe2f1222545a6a7e69c","url":"https://api.github.com/users/dominicsayers","id":34939,"login":"dominicsayers"}},"action":"created","issue":{"number":101,"created_at":"2011-09-22T15:04:03Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"When I use HTTParty to hit the Rubygems API, it falls over in the case of a gem that doesn't exist:\r\n\r\n```ruby\r\n$ irb -rhttparty\r\n>> HTTParty.get \"https://rubygems.org/api/v1/versions/doesnotexist.json\"\r\nMultiJson::DecodeError: lexical error: invalid char in json text.\r\n                                       This rubygem could not be found\r\n                     (right here) ------^\r\n\r\n\tfrom /Library/Ruby/Gems/1.8/gems/multi_json-1.0.3/lib/multi_json/engines/yajl.rb:10:in `parse'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/multi_json-1.0.3/lib/multi_json/engines/yajl.rb:10:in `decode'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/parser.rb:116:in `json'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/parser.rb:136:in `send'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/parser.rb:136:in `parse_supported_format'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/parser.rb:103:in `parse'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/parser.rb:66:in `call'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/request.rb:221:in `parse_response'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/request.rb:193:in `handle_response'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty/request.rb:75:in `perform'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty.rb:391:in `perform_request'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty.rb:343:in `get'\r\n\tfrom /Library/Ruby/Gems/1.8/gems/httparty-0.8.0/lib/httparty.rb:423:in `get'\r\n\tfrom (irb):1\r\n```\r\n\r\nUsing curl, the full response from the API call is:\r\n\r\n```\r\n$ curl -is https://rubygems.org/api/v1/versions/doesnotexist.json\r\nHTTP/1.1 404 Not Found\r\nDate: Thu, 22 Sep 2011 15:03:09 GMT\r\nServer: Apache/2.2.3 (Red Hat) mod_ssl/2.2.3 OpenSSL/0.9.8e-fips-rhel5 Phusion_Passenger/3.0.0\r\nX-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.0\r\nX-UA-Compatible: IE=Edge,chrome=1\r\nX-Runtime: 0.007590\r\nCache-Control: no-cache\r\nStatus: 404\r\nTransfer-Encoding: chunked\r\nContent-Type: application/json; charset=utf-8\r\n\r\nThis rubygem could not be found.\r\n```\r\n\r\nAm I using HTTParty incorrectly or is this a bug?","comments":11,"title":"HTTParty.get throws MultiJson::Decode error parsing Rubygems API response","updated_at":"2011-10-25T14:49:55Z","url":"https://api.github.com/repos/jnunemaker/httparty/issues/101","id":1714816,"assignee":null,"milestone":null,"closed_at":"2011-09-22T15:52:03Z","user":{"avatar_url":"https://secure.gravatar.com/avatar/72ee7b478a235f646c3495f03ebbe676?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"72ee7b478a235f646c3495f03ebbe676","url":"https://api.github.com/users/airblade","id":7265,"login":"airblade"},"html_url":"https://github.com/jnunemaker/httparty/issues/101","labels":[],"state":"closed"},"legacy":{"issue_id":1714816,"comment_id":2518085}}