def format_cause_backtrace(e, cause)
    # Find where the cause's backtrace differs from the parent exception's.
    backtrace       = Array(e.backtrace)
    cause_backtrace = Array(cause.backtrace)
    index = -1
    min_index = [backtrace.size, cause_backtrace.size].min * -1
    just_in_case = -5000

    while index > min_index && backtrace[index] == cause_backtrace[index] && index >= just_in_case
      index -= 1
    end

    # Add on a few common frames to make it clear where the backtraces line up.
    index += 3
    index = -1 if index >= 0

    cause_backtrace[0..index]
  end
def format_cause_backtrace(e, cause)
    # Find where the cause's backtrace differs from the parent exception's.
    backtrace       = Array(e.backtrace)
    cause_backtrace = Array(cause.backtrace)
    index = -1
    min_index = [backtrace.size, cause_backtrace.size].min * -1
    just_in_case = -5000

    while index > min_index && backtrace[index] == cause_backtrace[index] && index >= just_in_case
      index -= 1
    end

    # Add on a few common frames to make it clear where the backtraces line up.
    index += 3
    index = -1 if index >= 0

    cause_backtrace[0..index]
  end
Internal: Format the backtrace of the nested `cause` but remove the common
 exception lines from the parent exception. This helps keep the backtraces a
 wee bit shorter and more comprehensible.

 e     - parent exception
 cause - the nested exception generating the returned backtrace

 Returns an Array of backtracke lines.