Module: AiCli::Helpers::Error

Defined in:
lib/aicli/helpers/error.rb

Class Method Summary collapse

Class Method Details

.handle_cli_error(error) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aicli/helpers/error.rb', line 12

def handle_cli_error(error)
  return if error.is_a?(KnownError)

  pastel = Pastel.new
  indent = ' ' * 4

  if error.is_a?(StandardError) && error.backtrace
    puts pastel.dim(error.backtrace.join("\n"))
  end

  puts "\n#{indent}#{pastel.dim("ai v#{AiCli::VERSION}")}"
  puts "\n#{indent}#{I18n.t('Please open a Bug report with the information above')}:"
  puts "#{indent}https://github.com/magnum/aicli/issues/new"
end