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 280 def initialize(request, error) 281 @request = request 282 @response = request.response if request.response.is_a?(Response) 283 @error = error 284 @options = request.options 285 log_exception(@error) 286 finish! 287 end
Public Instance methods
<<(data)
buffers lost chunks to error response
[show source]
# File lib/httpx/response.rb 314 def <<(data) 315 return unless @response 316 317 @response << data 318 end
close()
closes the error resources.
[show source]
# File lib/httpx/response.rb 295 def close 296 @response.close if @response 297 end
finish!()
[show source]
# File lib/httpx/response.rb 304 def finish! 305 @request.connection = nil 306 end
finished?()
always true for error responses.
[show source]
# File lib/httpx/response.rb 300 def finished? 301 true 302 end
raise_for_status()
raises the wrapped exception.
[show source]
# File lib/httpx/response.rb 309 def raise_for_status 310 raise @error 311 end
to_s()
returns the exception full message.
[show source]
# File lib/httpx/response.rb 290 def to_s 291 @error.full_message(highlight: false) 292 end