Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney 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 '( path file line:pos)'. Then we have no words to translate while still providing the location information. Other places 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:{code}file line pos -> (file line:pos)file line -> (file line)file pos -> (file :pos)line pos -> (line:pos)file -> (file)line -> (line)pos -> (:pos){code}An example with all location information set:{code}11:20 $ bundle exec puppet apply foo.ppError: This Name has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form) (/Users/eric.delaney/work/my_repos/puppet/foo.pp 1:1)Error: This _expression_ is invalid. Did you try declaring a 'crazy' resource without a title? (/Users/eric.delaney/work/my_repos/puppet/foo.pp 1:9)Error: Language validation logged 2 errors. Giving up{code}Here is an example with no file path:{code}11:14 $ bundle exec puppet apply -e 'this is crazy {}'Error: This Name has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form) (1:1)Error: This _expression_ is invalid. Did you try declaring a 'crazy' resource without a title? (1:9)Error: Language validation logged 2 errors. Giving up{code}Places that need to update be updated : lib . /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: {code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code}
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney 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 '(path line:pos)'. Then we have no words to translate while still providing the location information.Other places to update:lib/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 {code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney For better translations we should look at refactoring how we handle exceptions that include add the location information to an error in ' file ExternalFileError ' . Instead of using words like 'at' , ' at line', and ' pos' of the error. Instead of using words can in" we should change to something like '(path line:pos)' . Then we have no words to translate while still providing the location information. Other places to update:lib/puppet/parser/resource.rb - def merge(resource) {code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney For better translations we should look at refactoring how we handle exceptions that include the 'file', 'line', and 'pos' of the error. Instead of using words can we change to something like ExternalFileError and the things built on it like ParseError and ResourceError. As you can see from the below code '(path line:pos)'Then we append have no words to a message based on line, file, and position information, but this makes it hard to translate while still providing the location information . Also note that these messages are not decorated for translation. {code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney For better translations we should look at refactoring how we handle exceptions that include the 'file', 'line', and 'pos' of the error. Instead of using words can we change to something like ExternalFileError and the things built on it like ParseError and ResourceError. As you can see from the below code we append to a message based on line, file, and position information, but this makes it hard to translate. Also note that these messages are not decorated for translation.{code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney Sprint: Platform Core Hopper Grooming Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney Sprint: Platform Core Hopper Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney Method Found: Needs Assessment Inspection Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Henrik Lindberg commented on PUP-8127 Re: Refacter ParseError and ResourceError for better I18n support The message and the file/line does not necessarily come from the same place - a typical case is that a lower level error occurs and the logic that raises it has no clue as to where it is in terms of "file and line in puppet" when that occurs. Instead the error is caught and the file/line information is added. Then, the error is both logged and formatted into the error message you see. The logging may be structured in which case file and line are not made into part of the message - that information goes into other slots in the format. Thus, we cannot simply put file/line into the message at the point where the error is raised. My preference would be that we changed the output to not include any words at all for file/line, just punctuation say (path line:pos), or (line:pos) or similar. If we must have words we do need to produce the "at file, line:pos" separately. Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney commented on PUP-8127 Re: Refacter ParseError and ResourceError for better I18n support Henrik Lindberg Ok, I was thinking we could find the places that we call it with the options file, line, or pos and convert them to pass a complete message instead and not pass the extra arguments. Essentially move the to_s() logic into the caller, and the just not pass in the options. At some future point you could remove the extra error logic. Would the be helpful or more painful later? Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney For better translations we should look at refactoring ExternalFileError and the things built on it like ParseError and Resource Error ResourceError . As you can see from the below code we append to a message based on line, file, and position information, but this makes it hard to translate. Also note that these messages are not decorated for translation.{code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Henrik Lindberg commented on PUP-8127 Re: Refacter ParseError and ResourceError for better I18n support I think there are additional places where almost the same thing is taking place. In general the use of various error types is a mess, not only for i18n purposes. It is a big thing to refactor all of it. Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney updated an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Change By: Eric Delaney For better translations we should look at refactoring ExternalFileError and the things built on it like ParseError and Resource Error. As you can see from the below code we append to a message based on line, file, and position information, but this makes it hard to translate. Also note that these messages are not decorated for translation. {code} 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? Exceptionoriginal = pospos = nil end super(message, original) @file = file unless (file.is_a?(String) && file.empty?) @line = line @pos = posenddef 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}" elsemsg endend end{code} Add Comment This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Jira (PUP-8127) Refacter ParseError and ResourceError for better I18n support
Title: Message Title Eric Delaney created an issue Puppet / PUP-8127 Refacter ParseError and ResourceError for better I18n support Issue Type: Bug Affects Versions: PUP 5.3.3 Assignee: Unassigned Created: 2017/11/07 8:29 AM Priority: Normal Reporter: Eric Delaney For better translations we should look at refactoring ExternalFileError and the things built on it like ParseError and Resource Error. As you can see from the below code we append to a message based on line, file, and position information, but this makes it hard to translate. module ExternalFileError # This module implements logging with a filename and line number. Use this # for errors that need to report a location in a