Module: Klenod::Build::ResolutionErrorFormatter

Defined in:
lib/klenod/build/resolution_error_formatter.rb

Constant Summary collapse

ANSI_BACKGROUND =
"\e[0;48;5;52m"

Class Method Summary collapse

Class Method Details

.format(error, source_root: nil, source_context: nil, ansi: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/klenod/build/resolution_error_formatter.rb', line 12

def format(error, source_root: nil, source_context: nil, ansi: false)
  return error.message unless error.resolution_failure?

  lines = [error.title, "", "  Import:      #{error.requested_specifier}"]
  lines << "  Imported by: #{error.imported_by}" if error.imported_by
  lines << "  Source root: #{source_root}" if source_root
  append_suggestions(lines, error)
  lines.concat(["", source_context]) if source_context
  text = lines.join("\n")
  ansi ? format_ansi(text) : text
end