Exception: HTTPX::HTTPError
- Defined in:
- lib/httpx/errors.rb
Overview
The exception class for HTTP responses with 4xx or 5xx status.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
The HTTPX::Response response object this exception refers to.
Instance Method Summary collapse
-
#initialize(response) ⇒ HTTPError
constructor
Creates the instance and assigns the HTTPX::Response
response
. -
#status ⇒ Object
The HTTP response status.
Constructor Details
#initialize(response) ⇒ HTTPError
Creates the instance and assigns the HTTPX::Response response
.
103 104 105 106 |
# File 'lib/httpx/errors.rb', line 103 def initialize(response) @response = response super("HTTP Error: #{@response.status} #{@response.headers}\n#{@response.body}") end |
Instance Attribute Details
#response ⇒ Object (readonly)
The HTTPX::Response response object this exception refers to.
100 101 102 |
# File 'lib/httpx/errors.rb', line 100 def response @response end |
Instance Method Details
#status ⇒ Object
The HTTP response status.
error.status #=> 404
111 112 113 |
# File 'lib/httpx/errors.rb', line 111 def status @response.status end |