Method: Puppet::Util::Errors.error_location

Defined in:
lib/puppet/util/errors.rb

.error_location(file, line = nil, column = nil) ⇒ String

Return a human-readable string of this object’s file, line, and pos attributes, if set.

Parameters:

  • file (String)

    the file path for the error (nil or “”, for not known)

  • line (String) (defaults to: nil)

    the line number for the error (nil or “”, for not known)

  • column (String) (defaults to: nil)

    the column number for the error (nil or “”, for not known)

Returns:

  • (String)

    description of file, line, and column



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/puppet/util/errors.rb', line 42

def self.error_location(file, line=nil, column=nil)
  file = nil if (file.is_a?(String) && file.empty?)
  line = nil if (line.is_a?(String) && line.empty?)
  column = nil if (column.is_a?(String) && column.empty?)
  if file and line and column
    _("(file: %{file}, line: %{line}, column: %{column})") % { file: file, line: line, column: column }
  elsif file and line
    _("(file: %{file}, line: %{line})") % { file: file, line: line }
  elsif line and column
    _("(line: %{line}, column: %{column})") % { line: line, column: column }
  elsif line
    _("(line: %{line})") % { line: line }
  elsif file
    _("(file: %{file})") % { file: file }
  else
    ''
  end
end