Module: DataShifter::Internal::RakeSetupOutput

Extended by:
RakeSetupOutput
Included in:
RakeSetupOutput
Defined in:
lib/data_shifter/internal/rake_setup_output.rb

Overview

Formatted stderr output when a rake data:shift task fails before the shift summary (load, constantize, etc.).

Constant Summary collapse

BACKTRACE_LIMIT =
12
DIVIDER =
"=" * 60
SEPARATOR =
"-" * 60

Instance Method Summary collapse

Instance Method Details



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/data_shifter/internal/rake_setup_output.rb', line 17

def print_failure(io:, exception:, file_path:, task_name:)
  lines = filtered_backtrace(exception, file_path)
  display = relative_display_path(file_path)

  io.puts ""
  io.puts Colors.red(DIVIDER, io:)
  io.puts Colors.error("DATA SHIFT SETUP FAILED", io:)
  io.puts Colors.dim(SEPARATOR, io:)
  io.puts "Rake task:   data:shift:#{task_name}"
  io.puts "File:        #{display}"
  io.puts Colors.dim(SEPARATOR, io:)
  io.puts Colors.error("#{exception.class}: #{exception.message}", io:)
  if lines.any?
    io.puts ""
    io.puts Colors.dim("Backtrace:", io:)
    lines.each { |line| io.puts Colors.dim("  #{line}", io:) }
  end
  io.puts Colors.red(DIVIDER, io:)
  io.puts ""
end