Class: HTTPX::ErrorResponse

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ErrorResponsePatternMatchExtensions, Loggable
Defined in:
lib/httpx/response.rb

Constant Summary

Constants included from Loggable

Loggable::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ErrorResponsePatternMatchExtensions

#deconstruct, #deconstruct_keys

Methods included from Loggable

#log, #log_exception

Constructor Details

#initialize(request, error, options) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



353
354
355
356
357
358
359
# File 'lib/httpx/response.rb', line 353

def initialize(request, error, options)
  @request = request
  @response = request.response if request.response.is_a?(Response)
  @error = error
  @options = Options.new(options)
  log_exception(@error)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



349
350
351
# File 'lib/httpx/response.rb', line 349

def error
  @error
end

#requestObject (readonly)

Returns the value of attribute request.



349
350
351
# File 'lib/httpx/response.rb', line 349

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



349
350
351
# File 'lib/httpx/response.rb', line 349

def response
  @response
end

Instance Method Details

#closeObject



377
378
379
# File 'lib/httpx/response.rb', line 377

def close
  @response.close if @response.respond_to?(:close)
end

#finished?Boolean

Returns:

  • (Boolean)


381
382
383
# File 'lib/httpx/response.rb', line 381

def finished?
  true
end

#raise_for_statusObject

Raises:



385
386
387
# File 'lib/httpx/response.rb', line 385

def raise_for_status
  raise @error
end

#statusObject



361
362
363
364
# File 'lib/httpx/response.rb', line 361

def status
  warn ":#{__method__} is deprecated, use :error.message instead"
  @error.message
end

#to_sObject



367
368
369
# File 'lib/httpx/response.rb', line 367

def to_s
  @error.full_message(highlight: false)
end