Class: HTTPX::ErrorResponse
- Inherits:
-
Object
- Object
- HTTPX::ErrorResponse
- Includes:
- Loggable
- Defined in:
- lib/httpx/response.rb
Constant Summary
Constants included from Loggable
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(request, error, options) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
-
#method_missing(meth, &block) ⇒ Object
rubocop:disable Style/MissingRespondToMissing.
- #raise_for_status ⇒ Object
- #reason ⇒ Object
- #status ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(request, error, options) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
261 262 263 264 265 266 |
# File 'lib/httpx/response.rb', line 261 def initialize(request, error, ) @request = request @error = error @options = Options.new() log_exception(@error) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, &block) ⇒ Object
rubocop:disable Style/MissingRespondToMissing
289 290 291 292 293 |
# File 'lib/httpx/response.rb', line 289 def method_missing(meth, *, &block) raise NoMethodError, "undefined response method `#{meth}' for error response" if Response.public_method_defined?(meth) super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
259 260 261 |
# File 'lib/httpx/response.rb', line 259 def error @error end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
259 260 261 |
# File 'lib/httpx/response.rb', line 259 def request @request end |
Instance Method Details
#body ⇒ Object
280 281 282 |
# File 'lib/httpx/response.rb', line 280 def body @error.backtrace.join("\n") end |
#headers ⇒ Object
276 277 278 |
# File 'lib/httpx/response.rb', line 276 def headers {} end |
#raise_for_status ⇒ Object
284 285 286 |
# File 'lib/httpx/response.rb', line 284 def raise_for_status raise @error end |
#reason ⇒ Object
272 273 274 |
# File 'lib/httpx/response.rb', line 272 def reason @error.class.name end |
#status ⇒ Object
268 269 270 |
# File 'lib/httpx/response.rb', line 268 def status @error. end |