Exception: Hurley::ClientError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ex, response = nil) ⇒ ClientError

Returns a new instance of ClientError.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/hurley.rb', line 53

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?(:status_code)
    super("the server responded with status #{ex.status_code}")
    @response = ex
  else
    super(ex.to_s)
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



51
52
53
# File 'lib/hurley.rb', line 51

def response
  @response
end

Instance Method Details

#backtraceObject



68
69
70
71
72
73
74
# File 'lib/hurley.rb', line 68

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

#inspectObject



76
77
78
# File 'lib/hurley.rb', line 76

def inspect
  %(#<#{self.class}: #{@wrapped_exception.class}>)
end