Sha256: 0d8fa9847b2e2657bd6c7ef7e744f5cf9a48cb5490493ae4811434d6779a41b8

Contents?: true

Size: 748 Bytes

Versions: 17

Compression:

Stored size: 748 Bytes

Contents

# frozen_string_literal: true
# Exception that is raised when an access to a resource is disallowed by
# robots.txt or by HTML document itself.

class Mechanize::RobotsDisallowedError < Mechanize::Error
  def initialize(url)
    if url.is_a?(URI)
      @url = url.to_s
      @uri = url
    else
      @url = url.to_s
    end
  end

  # Returns the URL (string) of the resource that caused this error.
  attr_reader :url

  # Returns the URL (URI object) of the resource that caused this
  # error.  URI::InvalidURIError may be raised if the URL happens to
  # be invalid or not understood by the URI library.
  def uri
    @uri ||= URI.parse(url)
  end

  def to_s
    "Robots access is disallowed for URL: #{url}"
  end
  alias :inspect :to_s
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mechanize-2.14.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.13.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.12.2 lib/mechanize/robots_disallowed_error.rb
mechanize-2.12.1 lib/mechanize/robots_disallowed_error.rb
mechanize-2.12.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.11.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.10.1 lib/mechanize/robots_disallowed_error.rb
mechanize-2.10.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.9.2 lib/mechanize/robots_disallowed_error.rb
mechanize-2.9.1 lib/mechanize/robots_disallowed_error.rb
mechanize-2.9.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.5 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.4 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.3 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.2 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.1 lib/mechanize/robots_disallowed_error.rb
mechanize-2.8.0 lib/mechanize/robots_disallowed_error.rb