Module: R10K::Errors::Formatting

Defined in:
lib/r10k/errors/formatting.rb

Class Method Summary collapse

Class Method Details

.format_exception(exc, with_backtrace = false) ⇒ String

Format this exception for displaying to the user

Parameters:

  • exc (Exception)

    The exception to format

  • with_backtrace (true, false) (defaults to: false)

    Whether the backtrace should be included with this exception

Returns:

  • (String)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/r10k/errors/formatting.rb', line 14

def format_exception(exc, with_backtrace = false)
  lines = []
  lines << exc.message
  if with_backtrace
    lines.concat(exc.backtrace)
  end
  if exc.respond_to?(:original) && exc.original
    lines << "Original exception:"
    lines<< format_exception(exc.original, with_backtrace)
  end
  lines.join("\n")
end