Sha256: 1038decd1bf12d58e1c0514c507545b84ccafd27ac9168f72967bfaff2eebae8

Contents?: true

Size: 856 Bytes

Versions: 10

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# 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
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(err)
    from_args(err.message, err.kind, err.details, err.issue_code)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bolt-0.20.6 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.20.5 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.20.3 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.20.2 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.20.0 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.19.1 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.19.0 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.18.2 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.18.1 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
bolt-0.18.0 bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb