<commit_before>module Dnsimple

  class Error < StandardError
  end

  # RequestError is raised when an API request fails for an client, a server error or invalid request information.
  class RequestError < Error
    attr_reader :http_response

    def initialize(http_response)
      @http_response = http_response
      super(http_response.parsed_response["message"])
    end
  end

  class NotFoundError < RequestError
  end

  class AuthenticationError < Error
  end

  class AuthenticationFailed < AuthenticationError
  end

end
<commit_msg>Use code as message for non JSON responses<commit_after>module Dnsimple

  class Error < StandardError
  end

  # RequestError is raised when an API request fails for an client, a server error or invalid request information.
  class RequestError < Error
    attr_reader :http_response

    def initialize(http_response)
      @http_response = http_response
      super(message_from(http_response))
    end

    private

    def message_from(http_response)
      if http_response.headers["Content-Type"] == "application/json"
        http_response.parsed_response["message"]
      else
        http_response.code
      end
    end

  end

  class NotFoundError < RequestError
  end

  class AuthenticationError < Error
  end

  class AuthenticationFailed < AuthenticationError
  end

end

{'fraction_non_alphanumeric': 0.046511627906976744, 'fraction_numerical': 0.0, 'mean_word_length': 3.522033898305085, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2932820', 'n_tokens_mistral': 366, 'n_tokens_neox': 350, 'n_words': 116}