lib/bitly/utils.rb in philnash-bitly-0.1.4 vs lib/bitly/utils.rb in philnash-bitly-0.2

- old
+ new

@@ -37,10 +37,14 @@ url.query << "&" + long_urls.map { |long_url| "longUrl=#{CGI.escape(long_url)}" }.join("&") unless long_urls.nil? url end def get_result(request) - result = JSON.parse(Net::HTTP.get(request)) + begin + result = Crack::JSON.parse(Net::HTTP.get(request)) + rescue + result = {'statusCode' => 'JSON Parse Error(Bit.ly messed up)', 'errorCode' => 69} + end if result['statusCode'] == "OK" result = result['results'] else raise BitlyError.new(result['errorMessage'],result['errorCode'],'expand') end \ No newline at end of file