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 = nil, response = nil) ⇒ Error

Returns a new instance of Error.



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

def initialize(exc = nil, 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



43
44
45
46
47
# File 'lib/faraday/error.rb', line 43

def response_body
  return unless @response

  @response.is_a?(Faraday::Response) ? @response.body : @response[:body]
end

#response_headersObject



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

def response_headers
  return unless @response

  @response.is_a?(Faraday::Response) ? @response.headers : @response[:headers]
end

#response_statusObject



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

def response_status
  return unless @response

  @response.is_a?(Faraday::Response) ? @response.status : @response[:status]
end