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.



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

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.



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

def body_io
  @body_io
end

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#mechanizeObject (readonly)

Returns the value of attribute mechanize.



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

def mechanize
  @mechanize
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#uriObject (readonly)

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#force_parseObject

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



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

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

#messageObject

:nodoc:



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

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