-
Type:
Bug
-
Status: Closed
-
Priority:
Normal
-
Resolution: Fixed
-
Affects Version/s: PUP 5.3.3
-
Component/s: None
-
Labels:None
-
Template:
-
Epic Link:
-
Sub-team:
-
Team:Platform Core
-
Sprint:Platform Core KANBAN
-
Method Found:Inspection
-
Release Notes:Bug Fix
-
Release Notes Summary:
-
QA Risk Assessment:No Action
For better translations we should look at how we add the location information to an error in 'ExternalFileError'. Instead of using words like 'at', 'at line', and 'in' we should change to something like '(file:line:pos)'. Then we have no words to translate while still providing the location information.
I think replacing the output with the below. Based on which variables are set the names on the left, would cause the output on the right:
file line pos -> (file:line:pos)
|
file line -> (file:line)
|
line pos -> (line:pos)
|
line -> (line)
|
An example with all location information set
Error: Something went wrong (/Users/eric.delaney/work/my_repos/puppet/foo.pp:1:9)
|
Error: Something went wrong (/Users/eric.delaney/work/my_repos/puppet/foo.pp:1)
|
Error: Something went wrong (1:9)
|
Error: Something went wrong (1)
|
Places that need to be updated:
./puppet/error.rb - ExternalFileError -> to_s
./puppet/parser/resource.rb - def merge(resource)
./puppet/pops/validation.rb - DiagnosticFormatterPuppetStyle
./puppet/util/errors.rb - Puppet::Util::Errors -> def error_context
./puppet/util/log.rb - Puppet::Util::Log -> to_s line 403
Some of the code that needs to be updated:
module ExternalFileError
|
# This module implements logging with a filename and line number. Use this
|
# for errors that need to report a location in a non-ruby file that we
|
# parse.
|
attr_accessor :line, :file, :pos
|
|
# May be called with 3 arguments for message, file, line, and exception, or
|
# 4 args including the position on the line.
|
#
|
def initialize(message, file=nil, line=nil, pos=nil, original=nil)
|
if pos.kind_of? Exception
|
original = pos
|
pos = nil
|
end
|
super(message, original)
|
@file = file unless (file.is_a?(String) && file.empty?)
|
@line = line
|
@pos = pos
|
end
|
def to_s
|
msg = super
|
@file = nil if (@file.is_a?(String) && @file.empty?)
|
if @file and @line and @pos
|
"#{msg} at #{@file}:#{@line}:#{@pos}"
|
elsif @file and @line
|
"#{msg} at #{@file}:#{@line}"
|
elsif @line and @pos
|
"#{msg} at line #{@line}:#{@pos}"
|
elsif @line
|
"#{msg} at line #{@line}"
|
elsif @file
|
"#{msg} in #{@file}"
|
else
|
msg
|
end
|
end
|
end
|