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.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/faraday/error.rb', line 11

def initialize(exc, response = nil)
  @wrapped_exception = nil
  @response = response

  if exc.respond_to?(:backtrace)
    super(exc.message)
    @wrapped_exception = exc
  elsif exc.respond_to?(:each_key)
    super("the server responded with status #{exc[:status]}")
    @response = exc
  else
    super(exc.to_s)
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#wrapped_exceptionObject (readonly)

Returns the value of attribute wrapped_exception.



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

def wrapped_exception
  @wrapped_exception
end

Instance Method Details

#backtraceObject



26
27
28
29
30
31
32
# File 'lib/faraday/error.rb', line 26

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

#inspectObject



34
35
36
37
38
39
40
# File 'lib/faraday/error.rb', line 34

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