Exception: Mechanize::ResponseCodeError
- Defined in:
- lib/mechanize/response_code_error.rb
Overview
This error is raised 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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
Instance Method Summary collapse
-
#initialize(page, message = nil) ⇒ ResponseCodeError
constructor
A new instance of ResponseCodeError.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(page, message = nil) ⇒ ResponseCodeError
Returns a new instance of ResponseCodeError.
11 12 13 14 15 16 |
# File 'lib/mechanize/response_code_error.rb', line 11 def initialize(page, = nil) super @page = page @response_code = page.code.to_s end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
9 10 11 |
# File 'lib/mechanize/response_code_error.rb', line 9 def page @page end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
8 9 10 |
# File 'lib/mechanize/response_code_error.rb', line 8 def response_code @response_code end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
18 19 20 21 22 23 |
# File 'lib/mechanize/response_code_error.rb', line 18 def to_s response_class = Net::HTTPResponse::CODE_TO_OBJ[@response_code] out = String.new("#{@response_code} => #{response_class} ") out << "for #{@page.uri} " if @page.respond_to? :uri # may be HTTPResponse out << "-- #{super}" end |