Wraps an error which has happened while processing an HTTP Request
. It has partial public API parity with HTTPX::Response
, so users should rely on it to infer whether the returned response is one or the other.
response = HTTPX.get("https://some-domain/path") #=> response is HTTPX::Response or HTTPX::ErrorResponse response.raise_for_status #=> raises if it wraps an error
Methods
Public Class
Public Instance
Included modules
Attributes
error | [R] |
the wrapped exception. |
request | [R] |
the corresponding |
response | [R] |
the |
Public Class methods
new(request, error)
[show source]
# File lib/httpx/response.rb 250 def initialize(request, error) 251 @request = request 252 @response = request.response if request.response.is_a?(Response) 253 @error = error 254 @options = request.options 255 log_exception(@error) 256 end
Public Instance methods
<<(data)
buffers lost chunks to error response
[show source]
# File lib/httpx/response.rb 279 def <<(data) 280 @response << data 281 end
close()
closes the error resources.
[show source]
# File lib/httpx/response.rb 264 def close 265 @response.close if @response && @response.respond_to?(:close) 266 end
finished?()
always true for error responses.
[show source]
# File lib/httpx/response.rb 269 def finished? 270 true 271 end
raise_for_status()
raises the wrapped exception.
[show source]
# File lib/httpx/response.rb 274 def raise_for_status 275 raise @error 276 end
to_s()
returns the exception full message.
[show source]
# File lib/httpx/response.rb 259 def to_s 260 @error.full_message(highlight: false) 261 end