Sha256: 22645da6e38bf26edd32a071f1ff20941a4a014167b65e077eeb0f759107a4a0

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

module WWW
  class Mechanize
    # =Synopsis
    # This class contains an error for when a pluggable parser tries to
    # parse a content type that it does not know how to handle.  For example
    # if WWW::Mechanize::Page were to try to parse a PDF, a ContentTypeError
    # would be thrown.
    class ContentTypeError < RuntimeError
      attr_reader :content_type
    
      def initialize(content_type)
        @content_type = content_type
      end
    end

    # =Synopsis
    # This error is thrown when Mechanize encounters a response code it does
    # not know how to handle.  Currently, this exception will be thrown
    # if Mechanize encounters response codes other than 200, 301, or 302.
    # Any other response code is up to the user to handle.
    class ResponseCodeError < RuntimeError
      attr_reader :response_code
      attr_reader :page
    
      def initialize(page)
        @page          = page
        @response_code = page.code
      end

      def to_s
        "#{response_code} => #{Net::HTTPResponse::CODE_TO_OBJ[response_code]}"
      end

      def inspect; to_s; end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mechanize-0.6.10 lib/mechanize/errors.rb
mechanize-0.6.11 lib/mechanize/errors.rb
mechanize-0.6.6 lib/mechanize/errors.rb
mechanize-0.6.5 lib/mechanize/errors.rb
mechanize-0.6.8 lib/mechanize/errors.rb
mechanize-0.6.7 lib/mechanize/errors.rb
mechanize-0.6.9 lib/mechanize/errors.rb