module Orientdb4r::ChainedError

This mixin extends an error to be able to track a chain of exceptions.

Attributes

cause[R]

Public Class Methods

new(message = nil, cause = $!) click to toggle source

Constructor.

Calls superclass method
# File lib/orientdb4r/chained_error.rb, line 11
def initialize message = nil, cause = $!
  super message unless message.nil?
  super $! if message.nil? and !cause.nil?
  @cause = cause
end

Public Instance Methods

set_backtrace(bt) click to toggle source

Modification of original method Error#set_backtrace to descend the full depth of the exception chain.

Calls superclass method
# File lib/orientdb4r/chained_error.rb, line 20
def set_backtrace bt
  unless cause.nil?
    cause.backtrace.reverse.each do |line|
      if bt.last == line
        bt.pop
        next
      end
      break
    end
    bt.push "<<<CAUSED BY>>>: #{cause.class}: #{cause.message}"
    bt.concat cause.backtrace
  end
  super bt
end