lib/medea/jasondeferredquery.rb in medea-0.3.2 vs lib/medea/jasondeferredquery.rb in medea-0.3.3

- old
+ new

@@ -112,12 +112,14 @@ def execute_query content=true #hit the URL #fill self.contents with :ghost versions of JasonObjects begin - #puts " = Executing #{type.name} deferred query! (#{to_url})" - result = JSON.parse(RestClient.get to_url) + LOGGER.debug "Executing #{type.name} deferred query! (#{to_url})" + + response = RestClient.get to_url + result = JSON.parse(response) self.contents = [] #results are in a hash, their keys are just numbers result.keys.each do |k| if k =~ /^[0-9]+$/ #this is a result! get the key @@ -134,9 +136,15 @@ end self.state = :postfetch result rescue + if response.code != 200 + LOGGER.error "Query to #{to_url} failed to parse!" + else + LOGGER.error "Query to #{to_url} failed to get!" + end + self.contents = [] end end end end