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 279 def initialize(request, error) 280 @request = request 281 @response = request.response if request.response.is_a?(Response) 282 @error = error 283 @options = request.options 284 log_exception(@error) 285 end
Public Instance methods
<<(data)
buffers lost chunks to error response
[show source]
# File lib/httpx/response.rb 310 def <<(data) 311 return unless @response 312 313 @response << data 314 end
close()
closes the error resources.
[show source]
# File lib/httpx/response.rb 293 def close 294 @response.close if @response 295 end
finished?()
always true for error responses.
[show source]
# File lib/httpx/response.rb 298 def finished? 299 true 300 end
raise_for_status()
raises the wrapped exception.
[show source]
# File lib/httpx/response.rb 305 def raise_for_status 306 raise @error 307 end
to_s()
returns the exception full message.
[show source]
# File lib/httpx/response.rb 288 def to_s 289 @error.full_message(highlight: false) 290 end