module Geocodable
  class GeocodableError < StandardError
    attr_reader :message
    attr_reader :http_status
    attr_reader :http_body

    def initialize(message=nil, http_status=nil, http_body=nil)
      @message = message
      @http_status = http_status
      @http_body = http_body
    end

    def to_s
      str = @http_status.nil? ? '' : "HTTP Status #{@http_status} "
      "#{str}#{@message}"
    end
  end

  class InvalidRequestError < GeocodableError; end
  class AuthenticationError < GeocodableError; end
  class AccessDisabledError < GeocodableError; end
  class OverRequestLimitError < GeocodableError; end
  class APIError < GeocodableError; end
end
