Exception: CemAcpt::Bolt::BoltActionError

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

Overview

Class for general Bolt errors. Can also wrap other errors.

Direct Known Subclasses

BoltInventoryError, BoltProjectError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = 'Bolt error occured', original_error = nil, bolt_action = nil, bolt_object = nil) ⇒ BoltActionError

Returns a new instance of BoltActionError.



9
10
11
12
13
14
15
16
17
18
# File 'lib/cem_acpt/bolt/errors.rb', line 9

def initialize(msg = 'Bolt error occured', original_error = nil, bolt_action = nil, bolt_object = nil)
  @original_error = original_error
  @bolt_action = bolt_action
  @bolt_object = bolt_object
  unless @original_error.nil?
    set_backtrace(@original_error.backtrace)
    msg = "#{msg}: #{@original_error}"
  end
  super(msg)
end

Instance Attribute Details

#bolt_actionObject (readonly)

Returns the value of attribute bolt_action.



7
8
9
# File 'lib/cem_acpt/bolt/errors.rb', line 7

def bolt_action
  @bolt_action
end

#bolt_objectObject (readonly)

Returns the value of attribute bolt_object.



7
8
9
# File 'lib/cem_acpt/bolt/errors.rb', line 7

def bolt_object
  @bolt_object
end

#original_errorObject (readonly)

Returns the value of attribute original_error.



7
8
9
# File 'lib/cem_acpt/bolt/errors.rb', line 7

def original_error
  @original_error
end

Instance Method Details

#bolt_targetObject



20
21
22
# File 'lib/cem_acpt/bolt/errors.rb', line 20

def bolt_target
  @bolt_target ||= @bolt_object&.target
end

#to_hObject



24
25
26
27
28
29
30
31
32
# File 'lib/cem_acpt/bolt/errors.rb', line 24

def to_h
  {
    bolt_action: bolt_action,
    bolt_object: bolt_object,
    original_error: original_error,
    message: message,
    backtrace: backtrace,
  }
end