Exception: R10K::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/r10k/errors.rb

Overview

An error class that accepts an optional hash and wrapped error message

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mesg) ⇒ Error #initialize(mesg, options) ⇒ Error

Returns a new instance of Error.

Overloads:

  • #initialize(mesg) ⇒ Error

    Parameters:

    • mesg (String)

      The exception mesg

  • #initialize(mesg, options) ⇒ Error

    Parameters:

    • mesg (String)

      The exception mesg

    • options (Hash)

      A set of options to store on the exception



32
33
34
35
36
37
38
39
40
41
# File 'lib/r10k/errors.rb', line 32

def initialize(mesg, options = {})
  super(mesg)

  bt = options.delete(:backtrace)
  if bt
    set_backtrace(bt)
  end

  @options = options
end

Instance Attribute Details

#originalObject

Returns the value of attribute original.



8
9
10
# File 'lib/r10k/errors.rb', line 8

def original
  @original
end

Class Method Details

.wrap(original, mesg, options = {}) ⇒ R10K::Error

Generate a wrapped exception

Parameters:

  • original (Exception)

    The exception to wrap

  • mesg (String)
  • options (Hash) (defaults to: {})

Returns:



17
18
19
20
21
22
# File 'lib/r10k/errors.rb', line 17

def self.wrap(original, mesg, options = {})
  new(mesg, options).tap do |e|
    e.set_backtrace(caller(4))
    e.original = original
  end
end