def check_response_errors(response)
      if !response.is_a?(Hash)
        raise RocketPants::Error, "The response from the server was not in a supported format."
      elsif response.has_key?("error")
        klass = RocketPants::Errors[response["error"]] || RocketPants::Error

        error_messages = if response.has_key?("messages")
          [response["messages"], response["error_description"]]
        else
          response["error_description"]
        end

        raise klass.new(*error_messages)
      end
    end
def check_response_errors(response)
      if !response.is_a?(Hash)
        raise RocketPants::Error, "The response from the server was not in a supported format."
      elsif response.has_key?("error")
        klass = RocketPants::Errors[response["error"]] || RocketPants::Error

        error_messages = if response.has_key?("messages")
          [response["messages"], response["error_description"]]
        else
          response["error_description"]
        end

        raise klass.new(*error_messages)
      end
    end
Processes a given response to check for the presence of an error,
 either by the response not being a hash (e.g. it is returning HTML instead
 JSON or HTTParty couldn't parse the response).
 @param [Hash, Object] response the response to check errors on
 @raise [RocketPants::Error] a generic error when the type is wrong, or a registered error subclass otherwise.