Exception: Rack::Remote::ChainedError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rack/remote.rb

Direct Known Subclasses

RemoteCallFailed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*attrs) ⇒ ChainedError

Returns a new instance of ChainedError.



16
17
18
19
20
21
22
# File 'lib/rack/remote.rb', line 16

def initialize(*attrs)
  if attrs.last.is_a?(Hash) && attrs.last[:cause].is_a?(Exception)
    @cause = attrs.last.delete(:cause)
    attrs.pop if attrs.last.empty?
  end
  super *attrs
end

Instance Attribute Details

#causeObject (readonly)

Returns the value of attribute cause.



14
15
16
# File 'lib/rack/remote.rb', line 14

def cause
  @cause
end

Instance Method Details

#set_backtrace(trace) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/rack/remote.rb', line 24

def set_backtrace(trace)
  trace.is_a?(Array) ? trace.map!(&:to_s) : trace = trace.to_s.split("\n")
  trace.map! { |line| "  #{line}" }
  if cause
    trace << "caused by #{cause.class.name}: #{cause.message}"
    trace += cause.backtrace.map! { |line| "  #{line}" }
  end
  super trace
end