vendored/puppet/lib/puppet/error.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/error.rb in bolt-0.20.5
- old
+ new
@@ -70,17 +70,12 @@
msg = _("%{message} on node %{node}") % { message: msg, node: node } if node
msg
end
def self.from_issue_and_stack(issue, args = {})
- stacktrace = Puppet::Pops::PuppetStack.stacktrace()
- if stacktrace.size > 0
- filename, line = stacktrace[0]
- else
- filename = nil
- line = nil
- end
+ filename, line = Puppet::Pops::PuppetStack.top_of_stack
+
self.new(
issue.format(args),
filename,
line,
nil,
@@ -105,6 +100,18 @@
# Raised when we failed to acquire a lock
class LockError < Puppet::Error
end
+ # An Error suitable for raising an error with details in a Puppet::Datatypes::Error
+ # that can be used as a value in the Puppet Language
+ #
+ class ErrorWithData < Puppet::Error
+ include ExternalFileError
+ attr_reader :error_data
+
+ def initialize(error_data, message, file: nil, line: nil, pos: nil, original:nil)
+ super(message, file, line, pos, original)
+ @error_data = error_data
+ end
+ end
end