lib/gurke/reporter.rb in gurke-2.1.0 vs lib/gurke/reporter.rb in gurke-2.2.1

- old
+ new

@@ -253,7 +253,34 @@ def invoke(mth, *args) send mth, *args rescue => e warn "Rescued in reporter: #{e}\n" + e.backtrace.join("\n") end + + + # @api private + # + protected + def format_exception(ex) + s = [ex.class.to_s + ': ' + ex.message.strip] + if ex.backtrace.nil? + s << ' <no backtrace available>' + elsif ex.backtrace.empty? + s << ' <backtrace empty>' + else + ex.backtrace.each do |bt| + s << ' ' + bt.strip + end + end + + if ex.respond_to?(:cause) && ex.cause && + ex.cause.respond_to?(:message) && ex.cause.respond_to?(:backtrace) + + cause = format_exception(ex.cause) + s << 'caused by: ' + cause.shift + s += cause + end + + s + end end end