Sha256: 28f5b8f37270f5d686129566b23057996c71acccb0aedcf802522158e992e177

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

# Raises a Bolt::PlanFailure exception to signal to callers that the plan failed
#
# Plan authors should call this function when their plan is not successful. The
# error may then be caught by another plans run_plan function or in bolt itself

require 'bolt/error'

Puppet::Functions.create_function(:fail_plan) do
  dispatch :from_args do
    param 'String[1]', :msg
    optional_param 'String[1]', :kind
    optional_param 'Hash[String[1], Any]', :details
    optional_param 'String[1]', :issue_code
  end

  dispatch :from_error do
    param 'Error', :error
  end

  def from_args(msg, kind = nil, details = nil, issue_code = nil)
    raise Bolt::PlanFailure.new(msg, kind || 'bolt/plan-failure', details, issue_code)
  end

  def from_error(e)
    from_args(e.message, e.kind, e.details, e.issue_code)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bolt-0.16.4 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.16.3 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.16.2 modules/boltlib/lib/puppet/functions/fail_plan.rb