Class: Ey::Core::Cli::Subcommand

Inherits:
Belafonte::App
  • Object
show all
Includes:
Helpers::Core
Defined in:
lib/ey-core/cli/subcommand.rb

Instance Method Summary collapse

Methods included from Helpers::Core

#core_account, #core_accounts, #core_application_for, #core_applications, #core_client, #core_environment_for, #core_environment_variables, #core_environments, #core_operator_and_environment_for, #core_server_for, #core_url, #core_yaml, #eyrc_yaml, included, #longest_length_by_name, #operator, #unauthenticated_core_client, #write_core_yaml

Instance Method Details

#handle_core_error(e) ⇒ Object

TODO: a lot more errors that would could handle with nice messages, eventually this should probably be it’s own class

Raises:

  • (SystemExit)


39
40
41
42
43
44
45
46
47
48
# File 'lib/ey-core/cli/subcommand.rb', line 39

def handle_core_error(e)
  stderr.puts "Error: #{e.error_type}".red
  (e.response.body["errors"] || [e.message]).each do |message|
    stderr.puts Wrapomatic.wrap(message, indents: 1)
  end
  if e.is_a?(Ey::Core::Response::Unauthorized)
    stderr.puts "Check the contents of ~/.ey-core vs https://cloud.engineyard.com/cli"
  end
  raise SystemExit.new(255)
end

#run_handleObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ey-core/cli/subcommand.rb', line 20

def run_handle
  super
rescue Ey::Core::Response::Error => e
  if ENV["DEBUG"]
    puts e.inspect
    puts e.backtrace
  end
  handle_core_error(e)
rescue => e
  if ENV["DEBUG"]
    puts e.inspect
    puts e.backtrace
  end
  stderr.puts "Error:".red
  stderr.puts Wrapomatic.wrap(e.message, indents: 1)
  raise SystemExit.new(255)
end

#setupObject



13
14
15
16
17
18
# File 'lib/ey-core/cli/subcommand.rb', line 13

def setup
  $stdout = stdout
  $stderr = stderr
  $stdin = stdin
  $kernel = kernel
end