Exception: Faraday::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/faraday/error.rb

Overview

Faraday error base class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exc, response = nil) ⇒ Error

Returns a new instance of Error.


9
10
11
12
13
# File 'lib/faraday/error.rb', line 9

def initialize(exc, response = nil)
  @wrapped_exception = nil unless defined?(@wrapped_exception)
  @response = nil unless defined?(@response)
  super(exc_msg_and_response!(exc, response))
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response


7
8
9
# File 'lib/faraday/error.rb', line 7

def response
  @response
end

#wrapped_exceptionObject (readonly)

Returns the value of attribute wrapped_exception


7
8
9
# File 'lib/faraday/error.rb', line 7

def wrapped_exception
  @wrapped_exception
end

Instance Method Details

#backtraceObject


15
16
17
18
19
20
21
# File 'lib/faraday/error.rb', line 15

def backtrace
  if @wrapped_exception
    @wrapped_exception.backtrace
  else
    super
  end
end

#inspectObject


23
24
25
26
27
28
29
# File 'lib/faraday/error.rb', line 23

def inspect
  inner = +''
  inner << " wrapped=#{@wrapped_exception.inspect}" if @wrapped_exception
  inner << " response=#{@response.inspect}" if @response
  inner << " #{super}" if inner.empty?
  %(#<#{self.class}#{inner}>)
end

#response_bodyObject


39
40
41
# File 'lib/faraday/error.rb', line 39

def response_body
  @response[:body] if @response
end

#response_headersObject


35
36
37
# File 'lib/faraday/error.rb', line 35

def response_headers
  @response[:headers] if @response
end

#response_statusObject


31
32
33
# File 'lib/faraday/error.rb', line 31

def response_status
  @response[:status] if @response
end