Exception: Bolt::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/bolt/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, kind, details = nil, issue_code = nil) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
10
11
# File 'lib/bolt/error.rb', line 5

def initialize(msg, kind, details = nil, issue_code = nil)
  super(msg)
  @kind = kind
  @issue_code = issue_code
  @details = details || {}
  @error_code ||= 1
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



3
4
5
# File 'lib/bolt/error.rb', line 3

def details
  @details
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



3
4
5
# File 'lib/bolt/error.rb', line 3

def error_code
  @error_code
end

#issue_codeObject (readonly)

Returns the value of attribute issue_code.



3
4
5
# File 'lib/bolt/error.rb', line 3

def issue_code
  @issue_code
end

#kindObject (readonly)

Returns the value of attribute kind.



3
4
5
# File 'lib/bolt/error.rb', line 3

def kind
  @kind
end

Class Method Details

.unknown_plan(plan) ⇒ Object



37
38
39
# File 'lib/bolt/error.rb', line 37

def self.unknown_plan(plan)
  "Could not find a plan named \"#{plan}\". For a list of available plans, run \"bolt plan show\""
end

.unknown_task(task) ⇒ Object



33
34
35
# File 'lib/bolt/error.rb', line 33

def self.unknown_task(task)
  "Could not find a task named \"#{task}\". For a list of available tasks, run \"bolt task show\""
end

Instance Method Details

#msgObject



13
14
15
# File 'lib/bolt/error.rb', line 13

def msg
  message
end

#to_hObject



17
18
19
20
21
22
23
# File 'lib/bolt/error.rb', line 17

def to_h
  h = { 'kind' =>  kind,
        'msg' => message,
        'details' => details }
  h['issue_code'] = issue_code if issue_code
  h
end

#to_json(opts = nil) ⇒ Object



25
26
27
# File 'lib/bolt/error.rb', line 25

def to_json(opts = nil)
  to_h.to_json(opts)
end

#to_puppet_errorObject



29
30
31
# File 'lib/bolt/error.rb', line 29

def to_puppet_error
  Puppet::DataTypes::Error.from_asserted_hash(to_h)
end