def error(response)
      if (response.content_type || "").include?("json")
        # Attempt to parse the error as JSON
        begin
          json = JSON.parse(response.body)

          if json["errors"] && json["errors"].first
            raise Error::HTTPError.new(json["errors"].first)
          end
        rescue JSON::ParserError; end
      end

      raise Error::HTTPError.new(
        "status"  => response.code,
        "message" => response.body
      )
    end
def error(response)
      if (response.content_type || "").include?("json")
        # Attempt to parse the error as JSON
        begin
          json = JSON.parse(response.body)

          if json["errors"] && json["errors"].first
            raise Error::HTTPError.new(json["errors"].first)
          end
        rescue JSON::ParserError; end
      end

      raise Error::HTTPError.new(
        "status"  => response.code,
        "message" => response.body
      )
    end
Raise a response error, extracting as much information from the server's
 response as possible.

 @raise [Error::HTTPError]

 @param [HTTP::Message] response
   the response object from the request