Exception: HTTPX::HTTPError

Inherits:
Error
  • Object
show all
Defined in:
lib/httpx/errors.rb

Overview

The exception class for HTTP responses with 4xx or 5xx status.

Direct Known Subclasses

MisdirectedRequestError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ HTTPError

Creates the instance and assigns the HTTPX::Response response.



91
92
93
94
# File 'lib/httpx/errors.rb', line 91

def initialize(response)
  @response = response
  super("HTTP Error: #{@response.status} #{@response.headers}\n#{@response.body}")
end

Instance Attribute Details

#responseObject (readonly)

The HTTPX::Response response object this exception refers to.



88
89
90
# File 'lib/httpx/errors.rb', line 88

def response
  @response
end

Instance Method Details

#statusObject

The HTTP response status.

error.status #=> 404


99
100
101
# File 'lib/httpx/errors.rb', line 99

def status
  @response.status
end