Module: Befog::Commands::Mixins::Safely

Included in:
Befog::CLI, Add, Configure, List, Remove, Run, Start, Stop
Defined in:
lib/befog/commands/mixins/safely.rb

Instance Method Summary collapse

Instance Method Details

#safelyObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/befog/commands/mixins/safely.rb', line 6

def safely
  begin
    yield
  rescue Befog::CLI::Error => e
    $stderr.puts "befog #{command.name}: #{e.message}"
    exit(-1)
  rescue => e # uh-oh
    $stderr.puts "Unexpected error"
    $stderr.puts "#{e.class}: #{e.message}"
    $stderr.puts e.backtrace
    exit(-1)
  end
end