class RainforestQA::ResponseExt::RaiseErrorFromJson

Public Instance Methods

on_complete(response) click to toggle source
# File lib/rainforestqa/response/raise_error_from_json.rb, line 8
def on_complete(response)
  code = response.status.to_i
  body = JSON.parse(response.body, :symbolize_names => true)

  # Error for invalid codes
  if !(200..300).include?(code)
    fail(RainforestQA::APIResponseError.new(body))
  else
    # How did we get here?
  end
end