Skip to content

Commit

Permalink
Merge pull request #24 from nicolaracco/master
Browse files Browse the repository at this point in the history
store raw response in InvalidAPIResponse
  • Loading branch information
intinig committed May 30, 2014
2 parents 5b897e9 + f0fa477 commit cd949c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/lol/invalid_api_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Lol
class InvalidAPIResponse < StandardError
attr_reader :raw

def initialize url, response
super "#{response["status"]["message"]} calling #{url}"
@raw = raw
end
end
end
4 changes: 2 additions & 2 deletions lib/lol/request.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "uri"
require "lol/invalid_api_response"

module Lol
class InvalidAPIResponse < StandardError; end
class NotFound < StandardError; end
class InvalidCacheStore < StandardError; end

Expand Down Expand Up @@ -53,7 +53,7 @@ def perform_request url

response = self.class.get(url)
raise NotFound.new("404 Not Found") if response.respond_to?(:code) && response.not_found?
raise InvalidAPIResponse.new(response["status"]["message"]) if response.is_a?(Hash) && response["status"]
raise InvalidAPIResponse.new(url, response) if response.is_a?(Hash) && response["status"]

store.setex clean_url(url), ttl, response.to_json if cached?

Expand Down

0 comments on commit cd949c3

Please sign in to comment.