Exception: Faraday::ClientError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ex, response = nil) ⇒ ClientError

Returns a new instance of ClientError.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/faraday/error.rb', line 8

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

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

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#wrapped_exceptionObject (readonly)

Returns the value of attribute wrapped_exception.



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

def wrapped_exception
  @wrapped_exception
end

Instance Method Details

#backtraceObject



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

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

#inspectObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/faraday/error.rb', line 31

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