Module: DaptivChefCI::RakeTaskHelpers

Extended by:
RakeTaskHelpers
Included in:
RakeTaskHelpers, Vagrant::RakeTask, VagrantDestroy::RakeTask, VagrantProvision::RakeTask, VagrantUp::RakeTask
Defined in:
lib/daptiv-chef-ci/raketask_helper.rb

Constant Summary collapse

@@exit_on_failure =
true

Instance Method Summary collapse

Instance Method Details

#execute(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/daptiv-chef-ci/raketask_helper.rb', line 15

def execute(&block)
  begin
    block.call()
  rescue SystemExit => ex
    if @@exit_on_failure
      exit(ex.status)
    else
      raise
    end
  rescue Exception => ex
    if @@exit_on_failure
      STDERR.puts("#{ex.message} (#{ex.class})")
      STDERR.puts(ex.backtrace.join("\n"))
      exit(1)
    else
      raise
    end
  end
end

#exit_on_failureObject



7
8
9
# File 'lib/daptiv-chef-ci/raketask_helper.rb', line 7

def exit_on_failure
  @@exit_on_failure
end

#exit_on_failure=(exit_on_failure) ⇒ Object



11
12
13
# File 'lib/daptiv-chef-ci/raketask_helper.rb', line 11

def exit_on_failure=(exit_on_failure)
  @@exit_on_failure = exit_on_failure
end