Exception: Mechanize::ResponseReadError

Inherits:
Error
  • Object
show all
Defined in:
lib/mechanize/response_read_error.rb

Overview

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.

Direct Known Subclasses

ChunkedTerminationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, response, body_io, uri, mechanize) ⇒ ResponseReadError

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



19
20
21
22
23
24
25
# File 'lib/mechanize/response_read_error.rb', line 19

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

Instance Attribute Details

#body_ioObject (readonly)

Returns the value of attribute body_io.



9
10
11
# File 'lib/mechanize/response_read_error.rb', line 9

def body_io
  @body_io
end

#errorObject (readonly)

Returns the value of attribute error.



10
11
12
# File 'lib/mechanize/response_read_error.rb', line 10

def error
  @error
end

#mechanizeObject (readonly)

Returns the value of attribute mechanize.



11
12
13
# File 'lib/mechanize/response_read_error.rb', line 11

def mechanize
  @mechanize
end

#responseObject (readonly)

Returns the value of attribute response.



12
13
14
# File 'lib/mechanize/response_read_error.rb', line 12

def response
  @response
end

#uriObject (readonly)

Returns the value of attribute uri.



13
14
15
# File 'lib/mechanize/response_read_error.rb', line 13

def uri
  @uri
end

Instance Method Details

#force_parseObject

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



30
31
32
# File 'lib/mechanize/response_read_error.rb', line 30

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

#messageObject

:nodoc:



34
35
36
# File 'lib/mechanize/response_read_error.rb', line 34

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