Exception: Gossip::MultiException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/gossip/multi-exceptions.rb

Overview

This collects exceptions from several threads and packages them up into a single exception.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exceptions) ⇒ MultiException

Returns a new instance of MultiException.



27
28
29
30
31
# File 'lib/gossip/multi-exceptions.rb', line 27

def initialize(exceptions)
  messages = exceptions.collect { | ex | "#{ex.to_s} (#{ex.class})" }
  super(messages.join("\n"))
  @traces = exceptions.collect { | ex | ex.backtrace }
end

Instance Attribute Details

#tracesObject (readonly)

Returns the value of attribute traces.



25
26
27
# File 'lib/gossip/multi-exceptions.rb', line 25

def traces
  @traces
end

Class Method Details

.reraise_with_combined_backtraceObject



33
34
35
36
37
38
39
40
41
# File 'lib/gossip/multi-exceptions.rb', line 33

def self.reraise_with_combined_backtrace
  yield
rescue MultiException => ex
  ex.traces.each_with_index { | trace, index | 
    trace.unshift("Trace number #{index}:\n")
  }
  ex.set_backtrace(ex.traces.flatten)
  raise
end