Class: HTTPX::ErrorResponse

Inherits:
Object
  • Object
show all
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.



314
315
316
317
318
319
# File 'lib/httpx/response.rb', line 314

def initialize(request, error, options)
  @request = request
  @error = error
  @options = Options.new(options)
  log_exception(@error)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



312
313
314
# File 'lib/httpx/response.rb', line 312

def error
  @error
end

#requestObject (readonly)

Returns the value of attribute request.



312
313
314
# File 'lib/httpx/response.rb', line 312

def request
  @request
end

Instance Method Details

#raise_for_statusObject

Raises:



337
338
339
# File 'lib/httpx/response.rb', line 337

def raise_for_status
  raise @error
end

#statusObject



321
322
323
324
# File 'lib/httpx/response.rb', line 321

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

#to_sObject



327
328
329
# File 'lib/httpx/response.rb', line 327

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