Method: Puppet::Util::Errors#fail

Defined in:
lib/puppet/util/errors.rb

#fail(message, ..) ⇒ Object #fail(error_klass, message, ..) ⇒ Object #fail(error_klass, message, ..) ⇒ Object

Throw an error, defaulting to a Puppet::Error.

Overloads:

  • #fail(message, ..) ⇒ Object

    Throw a Puppet::Error with a message concatenated from the given arguments.

    Parameters:

    • message (String)

      error message(s)

  • #fail(error_klass, message, ..) ⇒ Object

    Throw an exception of type error_klass with a message concatenated from the given arguments.

    Parameters:

    • type (Class)

      of error

    • message (String)

      error message(s)

  • #fail(error_klass, message, ..) ⇒ Object

    Throw an exception of type error_klass with a message concatenated from the given arguments.

    Parameters:

    • type (Class)

      of error

    • message (String)

      error message(s)

    • original (Exception)

      exception, source of backtrace info



149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/puppet/util/errors.rb', line 149

def fail(*args)
  if args[0].is_a?(Class)
    type = args.shift
  else
    type = Puppet::Error
  end

  other = args.count > 1 ? args.pop : nil
  error = adderrorcontext(type.new(args.join(" ")), other)

  raise error
end