def format_cause(e, lines)
    return lines if cause_depth == 0

    cause_depth.times do
      break unless e.respond_to?(:cause) && e.cause

      cause = e.cause
      lines << "--- Caused by ---"
      lines << "<#{cause.class.name}> #{cause.message}"
      lines.concat(format_cause_backtrace(e, cause)) if backtrace? && cause.backtrace

      e = cause
    end

    if e.respond_to?(:cause) && e.cause
      lines << "--- Further #cause backtraces were omitted ---"
    end

    lines
  end
def format_cause(e, lines)
    return lines if cause_depth == 0

    cause_depth.times do
      break unless e.respond_to?(:cause) && e.cause

      cause = e.cause
      lines << "--- Caused by ---"
      lines << "<#{cause.class.name}> #{cause.message}"
      lines.concat(format_cause_backtrace(e, cause)) if backtrace? && cause.backtrace

      e = cause
    end

    if e.respond_to?(:cause) && e.cause
      lines << "--- Further #cause backtraces were omitted ---"
    end

    lines
  end
Internal: Format any nested exceptions found in the given exception `e`
 while respecting the maximum `cause_depth`. The lines array is used to
 capture all the output lines form the nested exceptions; the array is later
 joined by the `format_obj` method.

 e     - Exception to format
 lines - Array of output lines

 Returns the input `lines` Array