lib/feedly_api.rb in feedly_api-0.5.0 vs lib/feedly_api.rb in feedly_api-0.5.1

- old
+ new

@@ -4,10 +4,12 @@ require 'feedly_api/errors' require 'feedly_api/client' require 'feedly_api/feed' module FeedlyApi + # A Ruby client library for Feedly Reader + API_ENDPOINT = 'http://cloud.feedly.com/v3/'.freeze class << self def get(url, token) uri = URI(url) @@ -20,18 +22,22 @@ response = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req) end + handle_errors(response) + end + + def handle_errors(response) raise BadRequest if 'null' == response.body case response.code.to_i when 200 then response.body when 401 then raise AuthError when 403 then raise AuthError when 404 then raise NotFound when 500 then raise Error - else + else raise Error end end end