Exception: Puppet::ParseErrorWithIssue

Inherits:
ParseError show all
Defined in:
lib/puppet/error.rb

Overview

Contains an issue code and can be annotated with an environment and a node

Direct Known Subclasses

PreformattedError

Instance Attribute Summary collapse

Attributes included from ExternalFileError

#file, #line, #pos

Attributes inherited from Error

#original

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, file = nil, line = nil, pos = nil, original = nil, issue_code = nil, arguments = nil) ⇒ ParseErrorWithIssue


60
61
62
63
64
65
# File 'lib/puppet/error.rb', line 60

def initialize(message, file=nil, line=nil, pos=nil, original=nil, issue_code= nil, arguments = nil)
  super(message, file, line, pos, original)
  @issue_code = issue_code
  @basic_message = message
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments


49
50
51
# File 'lib/puppet/error.rb', line 49

def arguments
  @arguments
end

#basic_messageObject (readonly)

Returns the value of attribute basic_message


49
50
51
# File 'lib/puppet/error.rb', line 49

def basic_message
  @basic_message
end

#environmentObject

Returns the value of attribute environment


50
51
52
# File 'lib/puppet/error.rb', line 50

def environment
  @environment
end

#issue_codeObject (readonly)

Returns the value of attribute issue_code


49
50
51
# File 'lib/puppet/error.rb', line 49

def issue_code
  @issue_code
end

#nodeObject

Returns the value of attribute node


50
51
52
# File 'lib/puppet/error.rb', line 50

def node
  @node
end

Class Method Details

.from_issue_and_stack(issue, args = {}) ⇒ Object


87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/puppet/error.rb', line 87

def self.from_issue_and_stack(issue, args = {})
  filename, line = Puppet::Pops::PuppetStack.top_of_stack

  self.new(
        issue.format(args),
        filename,
        line,
        nil,
        nil,
        issue.issue_code,
        args)
end

Instance Method Details

#to_hObject


74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/puppet/error.rb', line 74

def to_h
  {
    :issue_code => issue_code,
    :message => basic_message,
    :full_message => to_s,
    :file => file,
    :line => line,
    :pos => pos,
    :environment => environment.to_s,
    :node => node.to_s,
  }
end

#to_sObject


67
68
69
70
71
72
# File 'lib/puppet/error.rb', line 67

def to_s
  msg = super
  msg = _("Could not parse for environment %{environment}: %{message}") % { environment: environment, message: msg } if environment
  msg = _("%{message} on node %{node}") % { message: msg, node: node } if node
  msg
end