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 255 def initialize(request, error) 256 @request = request 257 @response = request.response if request.response.is_a?(Response) 258 @error = error 259 @options = request.options 260 log_exception(@error) 261 end
Public Instance methods
<<(data)
buffers lost chunks to error response
[show source]
# File lib/httpx/response.rb 284 def <<(data) 285 return unless @response 286 287 @response << data 288 end
close()
closes the error resources.
[show source]
# File lib/httpx/response.rb 269 def close 270 @response.close if @response 271 end
finished?()
always true for error responses.
[show source]
# File lib/httpx/response.rb 274 def finished? 275 true 276 end
raise_for_status()
raises the wrapped exception.
[show source]
# File lib/httpx/response.rb 279 def raise_for_status 280 raise @error 281 end
to_s()
returns the exception full message.
[show source]
# File lib/httpx/response.rb 264 def to_s 265 @error.full_message(highlight: false) 266 end