Sha256: 7616a0d94069fe1a1cb3d9fe009a35e1d2e843a84864e9a1cb3be8ae74ce7bac

Contents?: true

Size: 942 Bytes

Versions: 17

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true
##
# Raised when Mechanize encounters an error while reading the response body
# from the server.  Contains the response headers and the response body up to
# the error along with the initial error.

class Mechanize::ResponseReadError < Mechanize::Error

  attr_reader :body_io
  attr_reader :error
  attr_reader :mechanize
  attr_reader :response
  attr_reader :uri

  ##
  # Creates a new ResponseReadError with the +error+ raised, the +response+
  # and the +body_io+ for content read so far.

  def initialize error, response, body_io, uri, mechanize
    @body_io   = body_io
    @error     = error
    @mechanize = mechanize
    @response  = response
    @uri       = uri
  end

  ##
  # Converts this error into a Page, File, etc. based on the content-type

  def force_parse
    @mechanize.parse @uri, @response, @body_io
  end

  def message # :nodoc:
    "#{@error.message} (#{self.class})"
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

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