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.
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.
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.
# File lib/puppet/error.rb, line 30 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
May be called with 3 arguments for message, file, line, and exception, or 4 args including the position on the line.
# File lib/puppet/error.rb, line 20 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