Class: Nanoc::CLI::StackTraceWriter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/cli/stack_trace_writer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ StackTraceWriter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of StackTraceWriter.



6
7
8
# File 'lib/nanoc/cli/stack_trace_writer.rb', line 6

def initialize(stream)
  @stream = stream
end

Instance Method Details

#write(error, verbose:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nanoc/cli/stack_trace_writer.rb', line 10

def write(error, verbose:)
  count = verbose ? -1 : 10

  error.backtrace[0...count].each_with_index do |item, index|
    @stream.puts "  #{index}. #{item}"
  end

  if !verbose && error.backtrace.size > count
    @stream.puts "  ... #{error.backtrace.size - count} lines omitted (see crash.log for details)"
  end
end